Results 1 to 3 of 3

Thread: RTB and Listbox COLOR

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2006
    Posts
    124

    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:
    1. Private Sub cmdConvert_Click()
    2.     Dim x As Integer
    3.     txtColored.Text = ""
    4.     For x = 1 To Len(txtCode.Text)
    5.         If Mid(txtCode.Text, x, 1) = "^" Then
    6.             If Mid(txtCode.Text, x + 1, 1) = 0 Then
    7.                 txtColored.SelColor = vbBlack
    8.             ElseIf Mid(txtCode.Text, x + 1, 1) = 1 Then
    9.                 txtColored.SelColor = vbRed
    10.             ElseIf Mid(txtCode.Text, x + 1, 1) = 2 Then
    11.                 txtColored.SelColor = vbYellow
    12.             ElseIf Mid(txtCode.Text, x + 1, 1) = 3 Then
    13.                 txtColored.SelColor = vbGreen
    14.             ElseIf Mid(txtCode.Text, x + 1, 1) = 4 Then
    15.                 txtColored.SelColor = vbBlue
    16.             End If
    17.             x = x + 1
    18.         Else
    19.             txtColored.SelText = Mid(txtCode.Text, x, 1)
    20.         End If
    21.     Next x
    22. End Sub

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Dec 2006
    Posts
    124

    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 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
  •  



Click Here to Expand Forum to Full Width