Results 1 to 9 of 9

Thread: What I am missing here[UNRESOLVED]

  1. #1

    Thread Starter
    Lively Member hidroela's Avatar
    Join Date
    Mar 2004
    Posts
    107

    Unhappy What I am missing here[UNRESOLVED]

    What I am missing here I got this code

    VB Code:
    1. Public Enum ProcesorType
    2.     PLC3 = 0
    3.     PLC5_250 = 1
    4.     PLC5 = 2
    5.     SLC500 = 3
    6.     MicroLogix1000 = 4
    7. End Enum
    8.  
    9. Public Property Let ProcessorType(ByVal vData As ProcesorType)
    10.     On Error Resume Next
    11.     mvarProcessorType = vData
    12. End Property
    13.  
    14. Public Property Get ProcessorType() As ProcesorType
    15.     On Error Resume Next
    16.     ProcessorType = mvarProcessorType
    17. 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.

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    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
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    Lively Member hidroela's Avatar
    Join Date
    Mar 2004
    Posts
    107

    Re: What I am missing here

    Techgnome if this is what you are talking about

    VB Code:
    1. Public Property Get ProcessorType() As ProcesorType
    2.     On Error Resume Next
    3.     Select Case mvarProcessorType
    4.         Case 0
    5.             ProcessorType = "PLC-3"
    6.         Case 1
    7.             ProcessorType = "PLC-5/250"
    8.         Case 2
    9.             ProcessorType = "PLC-5"
    10.         Case 3
    11.             ProcessorType = "SLC 500"
    12.         Case 4
    13.             ProcessorType = "MicroLogix"
    14.     End Select
    15. End Property

    It did not work if you can show me and example I would be nice from you

    Best regards Hidroilio Pérez

  4. #4
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: What I am missing here

    Almost...
    VB Code:
    1. Public Property Get ProcessorType() As [b]String[/b]
    2.     On Error Resume Next
    3.     Select Case mvarProcessorType
    4.         Case 0
    5.             ProcessorType = "PLC-3"
    6.         Case 1
    7.             ProcessorType = "PLC-5/250"
    8.         Case 2
    9.             ProcessorType = "PLC-5"
    10.         Case 3
    11.             ProcessorType = "SLC 500"
    12.         Case 4
    13.             ProcessorType = "MicroLogix"
    14.     End Select
    15. End Property

    It needed to return a String.... not ProcessorType (which is a number).

    Tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  5. #5

    Thread Starter
    Lively Member hidroela's Avatar
    Join Date
    Mar 2004
    Posts
    107

    Re: What I am missing here

    thanks techgnome i will try it

    Best regards Hidroilio Pérez

  6. #6

    Thread Starter
    Lively Member hidroela's Avatar
    Join Date
    Mar 2004
    Posts
    107

    Re: What I am missing here

    well techgnome when i try this

    VB Code:
    1. Public Property Let ProcessorType(ByVal vData As ProcesorType)
    2.     On Error Resume Next
    3.     mvarProcessorType = vData
    4. End Property
    5. Public Property Get ProcessorType() As String
    6.     On Error Resume Next
    7.     Select Case mvarProcessorType
    8.         Case 0
    9.             ProcessorType = "PLC-3"
    10.         Case 1
    11.             ProcessorType = "PLC-5/250"
    12.         Case 2
    13.             ProcessorType = "PLC-5"
    14.         Case 3
    15.             ProcessorType = "SLC 500"
    16.         Case 4
    17.             ProcessorType = "MicroLogix"
    18.     End Select
    19. 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

  7. #7
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    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
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  8. #8

    Thread Starter
    Lively Member hidroela's Avatar
    Join Date
    Mar 2004
    Posts
    107

    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

  9. #9
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: What I am missing here

    Its the only way.

    VB Code:
    1. Public Property Let ProcessorType(ByVal vData As ProcesorType)
    2.     On Error Resume Next
    3.     mvarProcessorType = vData
    4. End Property
    5.  
    6. Public Property Get ProcessorType() As ProcesorType
    7.     On Error Resume Next
    8.     ProcessorType = mvarProcessorType
    9. End Property
    10.  
    11. Public Property Get ProcessorTypeDescription() As String
    12.     On Error Resume Next
    13.     Select Case mvarProcessorType
    14.         Case 0
    15.             ProcessorTypeDescription= "PLC-3"
    16.         Case 1
    17.             ProcessorTypeDescription= "PLC-5/250"
    18.         Case 2
    19.             ProcessorTypeDescription= "PLC-5"
    20.         Case 3
    21.             ProcessorTypeDescription= "SLC 500"
    22.         Case 4
    23.             ProcessorTypeDescription= "MicroLogix"
    24.         Case Else
    25.             ProcessorTypeDescription= ""
    26.     End Select
    27. 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
  •  



Click Here to Expand Forum to Full Width