What I am missing here[UNRESOLVED]
What I am missing here I got this code
VB Code:
Public Enum ProcesorType
PLC3 = 0
PLC5_250 = 1
PLC5 = 2
SLC500 = 3
MicroLogix1000 = 4
End Enum
Public Property Let ProcessorType(ByVal vData As ProcesorType)
On Error Resume Next
mvarProcessorType = vData
End Property
Public Property Get ProcessorType() As ProcesorType
On Error Resume Next
ProcessorType = mvarProcessorType
End Property
My problem is why I am getting for example a 4 when I am requesting the value of the ProcessorType Property rather than MicroLogix1000
Any help would be appreciated
Best regards Hidroilio Pérez :confused:
Re: What I am missing here
Because that's not how it works.... you've declared an enum with 5 possible values 0-4. The "names" are simply there to help the developer so that is isn't cryptic numbers all the time. If you want to return the actual name, then you need to declare an array that corresponds to the names, or use a select case to translate your number into the correct string.
tg
Re: What I am missing here
Techgnome if this is what you are talking about
VB Code:
Public Property Get ProcessorType() As ProcesorType
On Error Resume Next
Select Case mvarProcessorType
Case 0
ProcessorType = "PLC-3"
Case 1
ProcessorType = "PLC-5/250"
Case 2
ProcessorType = "PLC-5"
Case 3
ProcessorType = "SLC 500"
Case 4
ProcessorType = "MicroLogix"
End Select
End Property
It did not work if you can show me and example I would be nice from you
Best regards Hidroilio Pérez
Re: What I am missing here
Almost...
VB Code:
Public Property Get ProcessorType() As [b]String[/b]
On Error Resume Next
Select Case mvarProcessorType
Case 0
ProcessorType = "PLC-3"
Case 1
ProcessorType = "PLC-5/250"
Case 2
ProcessorType = "PLC-5"
Case 3
ProcessorType = "SLC 500"
Case 4
ProcessorType = "MicroLogix"
End Select
End Property
It needed to return a String.... not ProcessorType (which is a number).
Tg
Re: What I am missing here
thanks techgnome i will try it
Best regards Hidroilio Pérez :bigyello:
Re: What I am missing here
well techgnome when i try this
VB Code:
Public Property Let ProcessorType(ByVal vData As ProcesorType)
On Error Resume Next
mvarProcessorType = vData
End Property
Public Property Get ProcessorType() As String
On Error Resume Next
Select Case mvarProcessorType
Case 0
ProcessorType = "PLC-3"
Case 1
ProcessorType = "PLC-5/250"
Case 2
ProcessorType = "PLC-5"
Case 3
ProcessorType = "SLC 500"
Case 4
ProcessorType = "MicroLogix"
End Select
End Property
it Give me this error <<Definitions of property procedures for the same property are inconsistent or contain optional parameters or a ParamArray>>
Best regards Hidroilio Pérez :eek2:
Re: What I am missing here
Snark! Sorry about that.... You'll need to define two different properties, one defined as type ProcessorType, and one as type String. They simply cannot be the same name.
Tg
Re: What I am missing here
Thanks techgnome but I was hoping to some body come to a solution that not involved in creating another variable I appreciated your help
Best regards Hidroilio Pérez :wave:
Re: What I am missing here
Its the only way.
VB Code:
Public Property Let ProcessorType(ByVal vData As ProcesorType)
On Error Resume Next
mvarProcessorType = vData
End Property
Public Property Get ProcessorType() As ProcesorType
On Error Resume Next
ProcessorType = mvarProcessorType
End Property
Public Property Get ProcessorTypeDescription() As String
On Error Resume Next
Select Case mvarProcessorType
Case 0
ProcessorTypeDescription= "PLC-3"
Case 1
ProcessorTypeDescription= "PLC-5/250"
Case 2
ProcessorTypeDescription= "PLC-5"
Case 3
ProcessorTypeDescription= "SLC 500"
Case 4
ProcessorTypeDescription= "MicroLogix"
Case Else
ProcessorTypeDescription= ""
End Select
End Property