HAI,
i am in need to convert the string into long variable in vb 6.0
for example : if we type green it should be converted into its equivalent rgb
components
can any one suggest urgent reply needed
Printable View
HAI,
i am in need to convert the string into long variable in vb 6.0
for example : if we type green it should be converted into its equivalent rgb
components
can any one suggest urgent reply needed
Why not just use the RGB function or the VB color constants?
ie:
vb Code:
Me.BackColor = vbGreen Me.BackColor = RGB(0, 255, 0)
you can use vbGreen.
vb Code:
Private Sub Form_Load() Shape1.FillColor = vbGreen End Sub
Something like this? But you'll have to manually enter all the different Colour possibilities
Code:Private Type ColourList
ColourName As String
ColourValue As Long
End Type
Dim Colours(7) As ColourList
Private Sub Form_Load()
Colours(0) = SetColourInfo("Black", vbBlack)
Colours(1) = SetColourInfo("Blue", vbBlue)
Colours(2) = SetColourInfo("Cyan", vbCyan)
Colours(3) = SetColourInfo("Green", vbGreen)
Colours(4) = SetColourInfo("Magenta", vbMagenta)
Colours(5) = SetColourInfo("Red", vbRed)
Colours(6) = SetColourInfo("White", vbWhite)
Colours(7) = SetColourInfo("Yellow", vbYellow)
MsgBox GetColourLong("green")
End Sub
Private Function SetColourInfo(ColourName As String, ColourVal As Long) As ColourList
SetColourInfo.ColourName = ColourName
SetColourInfo.ColourValue = ColourVal
End Function
Private Function GetColourLong(StrName As String) As Long
Dim C As Integer
For C = 0 To UBound(Colours)
If LCase(Colours(C).ColourName) = LCase(StrName) Then
GetColourLong = Colours(C).ColourValue
Exit For
End If
Next
End Function
ok i resolved that problem thanks for ur reply