• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 175
  • Last Modified:

Structures instead of types....

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 vb.net 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
        MsgBox(Colorx)
        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",colors.red)  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.
0
clear100-com
Asked:
clear100-com
  • 2
1 Solution
 
Bob LearnedCommented:
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?

Bob
0
 
clear100-comAuthor Commented:
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.
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
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
0
 
clear100-comAuthor Commented:
Perfect!! That is what i wanted..
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now