Structures instead of types....

Posted on 2004-11-14
Last Modified: 2010-04-23
Hello, i use to use types in vb6, but now i use structures, thoght i didn't use types very well, i knew what they did and i knew what to do when i needed them.  Now i need them, but im playing around in trying to get myself ready to convert some major things to it.  Can you see what im trying to do here, and help me fix it?

Module Module1
    Public Structure Colors
        Public Red As String = "12121G1"
        Public Blue As String = "465C434"
        Public Green As String = "871X032"
        Public Yellow As String = "5B46873"
        Public Black As String = "A465468"
    End Structure
    Public Function NewFunction(ByVal Stuff As String, ByVal Colorx As Colors) As String
        Colorx.Red = Stuff
    End Function
End Module

Im trying to set it up so when i type under a form1.button1 the function like this: NewFunction("MyStringHere",  I want the user to see the list of colors after typing in the "colors." and then i want it to have that value when it executes the function.
Question by:clear100-com
    LVL 96

    Expert Comment

    by:Bob Learned
    VB.NET has a Color structure, and supporting color classes, so how are you trying to do something different.  What do the color values represent?


    Author Comment

    Actually, i was just using the names of colors just to use somthing, basicly let me explain this, you know when your typing msgbox("stuff"... and you hit the comma button on your keyboard and because this function "msgbox" has a list of items that you can choose like vbcancle etc... i want my function to have that list.
    LVL 85

    Accepted Solution

    What you are describing is an Enum, but they can only hold numbers, not strings:

    Module Module1

        Public Enum myValues
            Red = -3
            Blue = -1
            Green = 0
            Yellow = 1
            Black = 3
        End Enum

        Public Function myFunction(ByVal Stuff As String, ByVal myValue As myValues) As String
            Select Case myValue
                Case myValues.Red
                    Return "Red " & Stuff

                Case myValues.Blue
                    Return "Blue " & Stuff

                Case myValues.Green
                    Return "Green " & Stuff

                Case myValues.Yellow
                    Return "Yellow " & Stuff

                Case myValues.Black
                    Return "Black " & Stuff

            End Select
        End Function

    End Module

    Author Comment

    Perfect!! That is what i wanted..

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
    Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now