Dec 26th, 2006, 02:33 PM
#1
Thread Starter
Lively Member
RTB and Listbox COLOR
Hi,
i want to be able to colourise words in 2 different objects, richtextbox and listbox control, the code below got the rtb sorted..but i dont know how to use it for both, could somebody help make a module or something to do such a thing if possible.
VB Code:
Private Sub cmdConvert_Click()
Dim x As Integer
txtColored.Text = ""
For x = 1 To Len(txtCode.Text)
If Mid(txtCode.Text, x, 1) = "^" Then
If Mid(txtCode.Text, x + 1, 1) = 0 Then
txtColored.SelColor = vbBlack
ElseIf Mid(txtCode.Text, x + 1, 1) = 1 Then
txtColored.SelColor = vbRed
ElseIf Mid(txtCode.Text, x + 1, 1) = 2 Then
txtColored.SelColor = vbYellow
ElseIf Mid(txtCode.Text, x + 1, 1) = 3 Then
txtColored.SelColor = vbGreen
ElseIf Mid(txtCode.Text, x + 1, 1) = 4 Then
txtColored.SelColor = vbBlue
End If
x = x + 1
Else
txtColored.SelText = Mid(txtCode.Text, x, 1)
End If
Next x
End Sub
Dec 26th, 2006, 02:41 PM
#2
Re: RTB and Listbox COLOR
You can not color listbox items separately unless you do the drawing of items yourself.
Why are you using a textbox to choose the color? Should use a combo or such.
VB/Office Guru™ (AKA: Gangsta Yoda ™ ® )
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Dec 26th, 2006, 02:50 PM
#3
Thread Starter
Lively Member
Re: RTB and Listbox COLOR
codes an example for a game.
ill add a command for people to change thier display name.
displayname will be shown on the (userlist/players which is a listbox maybe i could use a different control like listview or something.)
and in the actual game window, which is a richtextbox.
other games manage to do it somehow.
Attached Images
Last edited by totaly; Dec 26th, 2006 at 03:05 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