|
-
Jul 18th, 2005, 06:59 PM
#1
Thread Starter
Lively Member
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
Last edited by hidroela; Jul 19th, 2005 at 05:39 PM.
-
Jul 18th, 2005, 07:58 PM
#2
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
-
Jul 18th, 2005, 08:28 PM
#3
Thread Starter
Lively Member
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
-
Jul 19th, 2005, 07:07 AM
#4
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
-
Jul 19th, 2005, 07:20 AM
#5
Thread Starter
Lively Member
Re: What I am missing here
thanks techgnome i will try it
Best regards Hidroilio Pérez
-
Jul 19th, 2005, 07:28 AM
#6
Thread Starter
Lively Member
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
-
Jul 19th, 2005, 10:54 AM
#7
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
-
Jul 19th, 2005, 11:03 AM
#8
Thread Starter
Lively Member
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
-
Jul 19th, 2005, 11:56 AM
#9
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|