Value of type ......

S

Supra

: error BC30311: Value of type 'System.Drawing.Color' cannot be
converted to 'Integer'.

Function doColor(ByVal rtb As RichTextBox, ByVal a As String, Optional
ByVal f As Integer = 0, Optional ByVal bg As Integer = 0)
Dim b As String, n, fgcolor, bgcolor As Integer

Dim colour(15) As Color
colour(0) = Color.White
colour(1) = Color.Black
colour(2) = Color.DarkBlue
colour(3) = Color.DarkGreen 'dark green
colour(4) = Color.Red 'red
colour(5) = Color.Brown
colour(6) = Color.Purple
colour(7) = Color.Orange
colour(8) = Color.Yellow
colour(9) = Color.LightGreen 'light green
colour(10) = Color.DarkMagenta 'dark blue green
colour(11) = Color.SkyBlue
colour(12) = Color.Blue 'light blue
colour(13) = Color.Magenta 'magenta
colour(14) = Color.Gray
colour(15) = Color.LightSlateGray

..
..
.. f = ColorTranslator.ToWin32(colour(fgcolor))
rtb.backcolour = colour(bgcolor) ===> error
occured here
APIHighlight2(bg, colour(fgcolor))
Debug.WriteLine(fgcolor)
...
..
..
..
..
End Function

how do i convert colour(bgcolor) into rtb.backcolor. this is irc chat
colour similar to mirc. it will worked in vb6. i tried this:...
ColorTranslator.ToWin32
color.fromArg
color.fromknowcolor
ColorTranslator.ToOle
directcast
ctype

regards,
 
C

Cor Ligthert

Supra,

Is your rtb a user control?
Because you use rtb.colour

This does give me a normal richtextbox with any color as background that I
choose:
Dim colour(15) As Color
colour(0) = Color.White
colour(1) = Color.Black
colour(2) = Color.DarkBlue
colour(3) = Color.DarkGreen 'dark green
colour(4) = Color.Red 'red
colour(5) = Color.Brown
colour(6) = Color.Purple
colour(7) = Color.Orange
colour(8) = Color.Yellow
colour(9) = Color.LightGreen 'light green
colour(10) = Color.DarkMagenta 'dark blue green
colour(11) = Color.SkyBlue
colour(12) = Color.Blue 'light blue
colour(13) = Color.Magenta 'magenta
colour(14) = Color.Gray
colour(15) = Color.LightSlateGray
rtb.backcolor = colour(5)

I hope this helps?

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top