Hello and forgive me for my very bad English first of all...
I'm not used to working with structures or enum...
I have many class in my project and i'm trying to organize.
My Class Duree Will contain Multiple enum or struct.
I would like to be able to call different enum or struct.
And build the request on the associated structure.
RepairList.vb
Public Class RepairList
Dim Tool As New Tools
Dim uuu As String = Tool.Find("C:\Data\1\" & Form1.TextBox2.Text & ".txt", "ProductType")
' Now uuu contains iPhone7,2
uuu = uuu.Replace(",", "")
uuu = uuu.Replace("i", "I")
uuu = uuu.Replace(" ", "")
uuu = uuu.Replace("P", "p")
' Now uuu contain Iphone72
Dim p As Devices.Device ' Class Devices --> Structure --> Device
Dim info As Reflection.FieldInfo = p.GetType().GetField(uuu)
Dim az As Object = info.GetValue(p)
' Now az contains Iphone 6
Dim toto As Object
toto = az
toto = toto.Replace(" ", "")
' Now toto contain Iphone6 the Name of the enum i woul catch in Duree
Dim test As String = myCheckbox.Name ' now test contains AntenneWifi
Dim value As Integer
value = CInt([Enum].Parse(GetType(Duree.Iphone6), test))
End Class
Devices.vb
Public Class Devices
Public Structure Device
Const Iphone41 = "Iphone 4S"
Const Iphone51 = "Iphone 5"
Const Iphone52 = "Iphone 5"
Const Iphone53 = "Iphone 5C"
Const Iphone54 = "Iphone 5C"
Const Iphone61 = "Ihpone 5S"
Const Iphone62 = "Iphone 5S"
Const Iphone71 = "Iphone 6 Plus"
Const Iphone72 = "Iphone 6"
Const Iphone81 = "Iphone 6S"
Const Iphone82 = "Iphone 6S Plus"
Const Iphone84 = "Iphone SE"
Const Iphone91 = "Iphone 7"
Const Iphone92 = "Iphone 7 Plus"
Const Iphone93 = "Iphone 7"
Const Iphone94 = "Iphone 7 Plus"
End Structure
End Class
Duree.vb
Public Class Duree
Public Enum Iphone5
'Define the Repair Time For each action.
AntenneWifi = 35
Batterie = 15
BtnVolDown = 45
BtnVolUp = 45
BtnHome = 20
BtnPower = 35
CableWifiBth = 35
CamAr = 30
MotherBoard = 30
FullScreen = 20
ScreenOnly = 40
HPExt = 35
HPInt = 25
SimLevier = 35
NappeHomeLong = 30
NappeBtnPower = 45
NappeFacetime = 30
NappeVolVibr = 40
PlaqueProtectLCD = 30
PriseJack = 40
SimTray = 2
Vibreur = 25
End Enum
Public Enum Iphone6
'Define the Repair Time For each action.
AntenneWifi = 35
Batterie = 15
BtnVolDown = 45
BtnVolUp = 45
BtnHome = 20
BtnPower = 35
CableWifiBth = 35
CamAr = 30
MotherBoard = 30
FullScreen = 20
ScreenOnly = 40
HPExt = 35
HPInt = 25
SimLevier = 35
NappeHomeLong = 30
NappeBtnPower = 45
NappeFacetime = 30
NappeVolVibr = 40
PlaqueProtectLCD = 30
PriseJack = 40
SimTray = 2
Vibreur = 25
End Enum
End Class
I put here only 2 enum but i have more in the Duree
class
So in RepairList.vb I would Replace Duree.Iphone6
in the following line
value = CInt([Enum].Parse(GetType(Durée.Iphone6), test))
By something like
value = CInt([Enum].Parse[GetType("Duree+" & toto), test))
But I can't find the right syntax.
Here is an overview of what I have looked at before
and many others ..
Thank's a lot if you can help me