|
-
Apr 8th, 2007, 12:46 AM
#1
Thread Starter
Member
Color Problem
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
-
Apr 8th, 2007, 01:32 AM
#2
Re: Color Problem
Why not just use the RGB function or the VB color constants?
ie:
vb Code:
Me.BackColor = vbGreen
Me.BackColor = RGB(0, 255, 0)
-
Apr 8th, 2007, 01:35 AM
#3
Re: Color Problem
you can use vbGreen.
vb Code:
Private Sub Form_Load()
Shape1.FillColor = vbGreen
End Sub
-
Apr 8th, 2007, 01:55 AM
#4
Re: Color Problem
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
-
Apr 8th, 2007, 02:01 AM
#5
Thread Starter
Member
Re: Color Problem
ok i resolved that problem thanks for ur reply
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
|