In my chat Program, it has the ability to send coloured messages.

So when a user sends a Message it would look like this
User1: Message, in black maybe....
User2: A message in red

At this stage all works well, but then ....

User1: Oh my god, my username is now the colour that appeared above.


Now this is definately not good. Anyways, I have little idea whats going on, so I've posted the full app on the forums, in the thread "Convert This App to VBA".

Anyway, heres some sections that I think might be reasponsible

VB Code:
  1. 'Found in the Toolbar, with messagelogtxt being the Sent Messages
  2. 'cdFont = CommonDialogBox
  3. 'messagetxt = Messages entered here.
  4.  
  5.  
  6. Case "Font"
  7. On Error Resume Next
  8. cdFont.Flags = cdlCFBoth
  9. cdFont.FontName = messageLogTXT.Font.Name
  10. cdFont.FontSize = messageLogTXT.Font.Size
  11. cdFont.FontBold = messageLogTXT.Font.Bold
  12. cdFont.FontItalic = messageLogTXT.Font.Italic
  13. cdFont.ShowFont
  14. With cdFont
  15. If .FontSize < 8 Then
  16.  
  17. messageTXT.Font.Name = .FontName
  18. messageTXT.Font.Size = .FontSize
  19. messageTXT.Font.Bold = .FontBold
  20. messageTXT.Font.Italic = .FontItalic
  21. Else
  22. Exit Sub
  23. End If
  24. End With
  25.  
  26.  
  27.  
  28.  
  29. Private Sub sendBTN_Click()
  30.     On Error Resume Next
  31.     Dim tempCommand As command
  32.    
  33. If Len(messageTXT.Text) > 300 Then
  34. Exit Sub
  35. End If
  36. If Len(messageTXT.Text) = 0 Then
  37. Exit Sub
  38. End If
  39.  
  40.     tempCommand.type = "MSG"
  41.     tempCommand.fromIP = getCurrentIP
  42.    
  43.     messageTXT.SelStart = 0
  44.     messageTXT.SelLength = Len(messageTXT.Text)
  45.     tempCommand.value = messageTXT.SelRTF
  46.     sendMessageToSelectedUsers tempCommand
  47.  
  48. '    For x = 0 To contactList.Count - 1
  49. '
  50. '        If contactList(x).sendTo Then
  51. '
  52. '            sendCommand_MessageSocket tempCommand, contactList(x).IP
  53. '
  54. '        End If
  55. '
  56. '    Next x
  57.  
  58.     messageTXT.Text = ""
  59.  
  60. End Sub



Does anything there look abit dodge??



Thanks in Advance.