|
-
Jun 18th, 2009, 04:58 PM
#1
Thread Starter
Lively Member
Font color in RichTextBox problem
I'm trying to set the font color in a richtextbox (rtbSample) based on the position of 3 scrollbars (scrRGB(0,1,2))and it's rgb value in a textbox (txtRGB) but it just won't work. Any ideas?
Code:
Private Sub scrRGB_Change(Index As Integer)
Dim CombinedValue As Long
CombinedValue = RGB(scrRGB(0).Value, scrRGB(1).Value, scrRGB(2).Value)
txtRGB.Text = "&H" & CombinedValue
picRGB.BackColor = CombinedValue
End Sub 'scrRGB_Change(Index As Integer)
Private Sub txtRGB_Change()
rtbSample.SelStart = 0
rtbSample.SelLength = Len(rtbSample.Text)
rtbSample.SelColor = txtRGB.Text
End Sub
Private Sub txtRGB_GotFocus()
If Len(txtRGB.Text) > 0 Then
txtRGB.SelStart = 0
txtRGB.SelLength = Len(txtRGB.Text)
End If
End Sub 'txtRGB_GotFocus()
-
Jun 18th, 2009, 05:49 PM
#2
Re: Font color in RichTextBox problem
Your conversion of an RGB Colour to a Hex Colour is incorrect.
Create the Hex Colour by concatenating the Hex value of each scroll bar but note that Hex Colours are in the form BBGGRR.
txtRGB.Text = "&H" & Format$(Hex(scrRGB(2).Value), "00") & Format$(Hex(scrRGB(1).Value), "00") & Format$(Hex(scrRGB(0).Value), "00")
or simply set the rtbSample.SelColor = picRGB.BackColor
Last edited by brucevde; Jun 18th, 2009 at 05:53 PM.
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
|