Author | Message | Time |
---|---|---|
FiReGoD | [code]Private Sub access_BnetDisconnected() frmBot.ShowTxt "< Disconnected from Bnet >" & vbCrLf access.Disconnect txtChannel.Text = " " frmBot.ListBox1.Clear End Sub[/code] how do i make that red in my richtextbox frmBot.ShowTxt "< Disconnected from Bnet >" & vbCrLf, vbred? | February 26, 2003, 6:53 PM |
Spht | Let's see your ShowTxt() function. | February 26, 2003, 7:02 PM |
FiReGoD | [code]Public Sub ShowTxt(strTxt As String) 'Show text in main chat box, and scroll to end txtChat.Text = txtChat.Text & "[" & Time & "]" & strTxt txtChat.SelStart = Len(txtChat.Text) With txtChat If Len(.Text) > 31200 Then txtChat = " " End If End With End Sub[/code] | February 26, 2003, 7:03 PM |
Spht | Instead of me modifying your code, may I suggest that you use Grok's excellent AddChat subroutine? [code]Private Sub AddChat(ParamArray saElements() As Variant) Dim i As Integer For i = LBound(saElements) To UBound(saElements) Step 2 With txtChat .SelStart = Len(.Text) .SelLength = 0 .SelColor = saElements(i) .SelText = saElements(i + 1) & Left$(vbCrLf, -2 * CLng((i + 1) = UBound(saElements))) .SelStart = Len(.Text) End With Next i End Sub[/code] This supports passing text with multiple colors. For example: AddChat vbWhite, "<", vbYellow, "Spht", vbWhite, "> Hello." | February 26, 2003, 7:16 PM |
Camel | feh...doesnt have string array input, but whatcha gonna do? [code]Public Enum MyColorConsts ColInfo = vbYellow ColAnnounce = vbMagenta ColMyText = vbWhite ColMyUn = vbCyan ColMyEmote = vbYellow colTalkText = vbWhite ColTalkUn = vbYellow ColTalkOpText = vbWhite ColTalkOpUn = vbWhite ColTalkBlizText = vbCyan ColTalkBlizUn = vbCyan ColEncrypt = vbMagenta ColProfile = vbWhite ColChannel = vbGreen ColJoinPart = vbGreen ColAnError = vbRed ColEmote = vbYellow ColEmoteOp = vbWhite ColEmoteBliz = vbCyan ColWhisperUn = vbCyan ColWhisperText = &H808080 ColWhisperFromUn = vbYellow ColWhisperFromText = &H808080 End Enum Public Sub ClearChat() Dim x, Y As Integer x = Len(frmMain.txtChat.Text) If x = 0 Then Exit Sub 'bleh, dont hit then before any connections :( For Y = 1 To 100 x = InStrRev(frmMain.txtChat.Text, vbCrLf, x, vbBinaryCompare) If x = 0 Then Exit Sub 'GoTo bailchop Next frmMain.txtChat.Text = Right(frmMain.txtChat.Text, Len(frmMain.txtChat.Text) - x) frmMain.txtChat.SelStart = 0 frmMain.txtChat.SelLength = Len(frmMain.txtChat.Text) frmMain.txtChat.SelColor = &HA0A0A0 frmMain.txtChat.SelStart = Len(frmMain.txtChat.Text) frmMain.txtSend.SetFocus End Sub Public Sub AddText(style As MyColorConsts, ByVal mytext As String, ByVal UseTimeStamp As Boolean) Dim x As Integer Do x = InStr(x + 1, mytext, "˙C") If x > 0 Then Dim color As ColorConstants color = 0 Select Case (Mid(mytext, x + 2, 1)) Case "0": color = RGB(208, 208, 208) 'white Case "1": color = RGB(208, 64, 64) 'red Case "2": color = RGB(0, 208, 0) 'green Case "3": color = RGB(88, 88, 208) 'vbBlue Case "4": color = 0 'fixme:beige Case "5": color = &H545454 'gray Case "6": color = vbBlack 'will this show? Case "7": color = RGB(160, 160, 100) 'fixme:beige Case "8": color = RGB(208, 136, 0) 'orange Case "9": color = RGB(208, 208, 80) 'lt.yellow End Select '˙C1 text displays RED text '˙C2 text displays GREEN text '˙C3 text displays BLUE text '˙C4 text displays BEIGE text '˙C5 text displays GRAY text '˙C6 text displays BLACK text '˙C7 text displays BEIGE text '˙C8 text displays ORANGE text '˙C9 text displays YELLOW text If color <> 0 Then Addtext style, Left(mytext, x - 1), usetimestampp Addtext color, Mid(mytext, x + 3), False Exit Sub End If End If Loop While x > 0 With frmMain.txtChat If Len(.TextRTF) > 65535 Then ClearChat If (UseTimeStamp = True) And (frmSetup.TSType > 0) Then .SelStart = Len(.Text) .SelLength = 0 .SelColor = vbWhite Select Case frmSetup.TSType Case 1 .SelText = "[" & Zero(DatePart("h", Now), 2) & _ ":" & Zero(DatePart("m", Now), 2) & _ ":" & Zero(DatePart("s", Now), 2) & _ "] " Case Else '2 .SelText = "[" & Date & " " & Time & "] " End Select End If .SelStart = Len(.Text) .SelLength = 0 .SelColor = style .SelText = mytext End With bailchop: End Sub[/code] | February 26, 2003, 7:17 PM |
Camel | hrm, let me break that down in to n00blish for ya [code]Public Sub AddText(style As ColorConstants, ByVal mytext As String, ByVal UseTimeStamp As Boolean) With frmMain.txtChat 'NB: this is an rtb, NOT a regular text box!! If (UseTimeStamp = True) Then .SelStart = Len(.Text) .SelLength = 0 .SelColor = vbWhite .SelText = "[" & Date & " " & Time & "] " End If .SelStart = Len(.Text) .SelLength = 0 .SelColor = style .SelText = mytext End With End Sub[/code][/quote] [edit]hrm, i didnt realise that was going to look exactly like what spht posted... | February 26, 2003, 7:22 PM |
MesiaH | it doesnt because groks sub allows an unlimited amount of input types, longs, strings, integers, dont matter, in your case, you have to use one color, each time. Although in vb, groks sub would actually be slower, because you dont declare the type the data is, so vb has to figure it out on its own, which can kill a couple milliseconds, so remember, if you add anything to your RTB when you send 0x25, be sure to add it AFTER you send the data back to bnet, cause it slows u down drasticly (As shown in my xbot compared to my buddhabot, xbot uses the 2 color, 2 text adding routine, compared to buddha which uses a modified version of groks sub, xbot gets half second logins, compared to buddha which can lag a tiny bit before login, and xbot adds like 8 things to the rtb also). But anyways, yeah groks is bigger and better :-p | February 26, 2003, 10:38 PM |
St0rm.iD | February 26, 2003, 10:50 PM |