Valhalla Legends Archive

Programming => General Programming => Visual Basic Programming => Topic started by: Crim-Training on October 21, 2003, 12:20 AM

Title: Multiple RTB
Post by: Crim-Training on October 21, 2003, 12:20 AM
im trying to add 2 seperate rich txt box's to my form, but i dont know how to edit the module can someone help me ?

this is what i got so far

Public Function AddChat(ByVal txtOne As String, ByVal clrOne As Long, Optional ByVal txtTwo As String, Optional ByVal clrTwo As Long, Optional ww As Integer)
   Dim txtchat1 As RichTextBox
    On Error Resume Next
   If ww = 1 Then
       Set txtchat1 = Form1.Talk
   Else
       Set txtchat1 = Form1.Talk
   End If
   
   With txtchat1
       .SelStart = Len(.Text)
       .SelLength = 0
       .SelColor = vbWhite
       .SelText = "[" & Time & "] "
       .SelColor = clrOne
       .SelText = txtOne
   End With

   If Len(txtTwo) > 1 Then
      With txtchat1
          .SelStart = Len(.Text)
          .SelLength = 0
          .SelColor = clrTwo
          .SelText = txtTwo
      End With
   End If
End Function


any help is appreciated
Title: Re:Multiple RTB
Post by: bmwrb16 on October 21, 2003, 06:24 AM
Err g2g i'll help you in like 3 hours
Title: Re:Multiple RTB
Post by: CrAz3D on October 21, 2003, 08:54 AM
Try copy & pasting that AddChat sub & call it, for example, AddChat2.  Then just make AddChat2 add the text to the other RTB.
Title: Re:Multiple RTB
Post by: Crim-Training on October 21, 2003, 08:59 AM
thx CrAz3D, i love you
Title: Re:Multiple RTB
Post by: CupHead on October 21, 2003, 09:27 AM
Rather than making an entirely new function, it might be easier to just specify the RTB in the arguments like so:


Public Function AddChat(RTB as RichTextBox, ByVal txtOne As String, ByVal clrOne As Long, Optional ByVal txtTwo As String, Optional ByVal clrTwo As Long)
   On Error Resume Next
   
   With RTB
       .SelStart = Len(.Text)
       .SelLength = 0
       .SelColor = vbWhite
       .SelText = "[" & Time & "] "
       .SelColor = clrOne
       .SelText = txtOne
   End With

   If Len(txtTwo) > 1 Then
     With RTB
         .SelStart = Len(.Text)
         .SelLength = 0
         .SelColor = clrTwo
         .SelText = txtTwo
     End With
   End If
End Function
Title: Re:Multiple RTB
Post by: Crim-Training on October 21, 2003, 09:33 AM
thx they both work, greatly appreciated
Title: Re:Multiple RTB
Post by: bmwrb16 on October 21, 2003, 12:14 PM
Yeah, i was going to so that bleh..