Results 1 to 10 of 10

Thread: Changing colors

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2002
    Location
    Louisville, KY
    Posts
    8

    Changing colors

    I am printing out two strings from two different text files next to one another in text boxes in two different byte arrays. For example:

    4A 4A
    5C 00
    66 66
    58 00
    47 47
    4C 00
    4D 4D
    4E 00
    4F 4F
    FF 00
    FF FF

    My boss wants me to turn the ones that are different red, and the ones that are the same to stay black. For example:

    4A 4A
    5C 00
    66 66
    58 00
    47 47
    4C 00
    4D 4D
    4E 00
    4F 4F
    FF 00
    FF FF

    How would I tell my program with code to change the color of the ones that do not match?

    Thanks!

    Also, if you need to refer to the code I already have for the program, just tell me and I can get that for you right away. Thanks again everyone!!!!!

  2. #2
    Lively Member
    Join Date
    Jun 2002
    Posts
    81
    add rich text box call it rich1
    and use the code
    rich1.SelColor = vbRed
    rich1.SelText = "red text" + vbNewLine
    for red
    and
    rich1.SelColor = vbBlack
    rich1.SelText = "blacktext" + vbNewLine

    hope ive helped

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2002
    Location
    Louisville, KY
    Posts
    8
    is there a difference between a rich text box and a regular one?

    Also, my boss just wants the two text boxes that I already have. He wants the text in the byte arrays to turn red. Is that even possible?


  4. #4
    Lively Member
    Join Date
    Jun 2002
    Posts
    81
    rich text box can display multiple colors and textbox can only one forecolor...
    if you wont change the textboxes you use to richtextbox, you cant use multiple color.

  5. #5

    Thread Starter
    New Member
    Join Date
    May 2002
    Location
    Louisville, KY
    Posts
    8
    How do I change the text box I have now to a rich text box?

  6. #6
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    Originally posted by JenniGE

    Also, my boss just wants the two text boxes that I already have. He wants the text in the byte arrays to turn red. Is that even possible?

    Usage of the RTB may add a bit to the overall size of the project, but based upon the criteria he's given you, it's your best choice. You might also want to go for several labels... a little hectic, but can do the thing you want it to.

  7. #7
    Junior Member
    Join Date
    Apr 2002
    Location
    Michigan
    Posts
    27

    try this

    You can change forecolor of textboxes. Maybe this isnt what you wanted but if it is it works fine with textboxes.
    i did it with a command button but you could put it in one of the textboxes validate commands as well i think.
    VB Code:
    1. Private Sub Command1_Click()
    2. If Text1 = Text2 Then
    3. Text1.ForeColor = vbRed
    4. Text2.ForeColor = vbRed
    5. Else
    6. Text1.ForeColor = black
    7. Text2.ForeColor = black
    8. End If
    9. End Sub
    Rj

  8. #8
    Lively Member
    Join Date
    Jun 2002
    Posts
    81
    to replace the existing textboxes with Richtextboxes
    just right click on the toolbar select components then select the richtextbox from the list
    add the richtextbox to the form and change the name to the same name as the textbox, then instead of using text1.text=text1.text+"..."
    use text1.seltext="..."
    (text1.text="..." will cause you to display only in one color)

  9. #9
    Lively Member
    Join Date
    Jun 2002
    Posts
    81
    rjcarroll , using the button you gave will cuase the whole textbox to display the same color (red or black) and he wanted to display some of the lines as black and some of them as red in the same textbox...
    richtextbox is the solution.

  10. #10
    Junior Member
    Join Date
    Apr 2002
    Location
    Michigan
    Posts
    27

    sound good to me

    thanks mrfixit. like i said " may not be what he wants (but)"
    i didnt realize he was using multilines. thought he was showing just one result in text1 and 2 at a time.
    Rj

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