• Welcome to Valhalla Legends Archive.
 

Timestamp help

Started by MrRaza, March 06, 2003, 04:19 AM

Previous topic - Next topic

MrRaza

I want to add a timestamp to my rtb along with some text in this fashion.

<timestamp> Name, SentData


Any help would be appreciated.

Grok

#1
rtb.SelText = Format(Now, "YYYY-MM-DD HH:MM:SS") & " <" & Name & "> " & MessageText

Like that?

iago

#2
Doesn't vb have a built-in variable $time?  Or was that QBasic?  I dunno, but try that :)
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


MrRaza

#3
Quotertb.SelText = Format(Now, "YYYY-MM-DD HH:MM:SS") & " <" & Name & "> " & MessageText

Like that?

What if I used AddChat vbRed, Format(Now, "YYYY-MM-DD HH:MM:SS") & "SentData"

Would that work also.
 ?

Spht

#4
QuoteWhat if I used AddChat vbRed, Format(Now, "YYYY-MM-DD HH:MM:SS") & "SentData"

Would that work also.
 ?

Depends on what you mean by "work."
That will show "SendData" stuck to the time and it also means that you're going to have to manually insert timestamp each time you call AddChat()... unless you want it that way.

In the AddChat() function, I insert the timestamp, then go on to display the inputted data.

'Grok's (of Clan [vL]) RTB colored text subprocedure with slight modifications.
Public Sub AddChat(ParamArray paElements() As Variant)
    Dim i&

    With frmMain.rtfChat
        .SelStart = Len(.Text)
        .SelLength = 0
        .SelColor = RGB(127, 127, 127)
        .SelText = "[" & Format(Time, "HH:MM:SS") & "] "
        .SelStart = Len(.Text)
        For i = LBound(paElements) To UBound(paElements) Step 2
            .SelStart = Len(.Text)
            .SelLength = 0
            .SelColor = paElements(i)
            .SelText = paElements(i + 1) & Left(vbCrLf, -2 * CLng((i + 1) = UBound(paElements)))
            .SelStart = Len(.Text)
        Next i
    End With
End Sub

frmMain.rtfChat would of course be your pointer to the RTB control.

MrRaza

#5
Thanks

Grok

#6
Expanding on that, add a global boolean to toggle timestamping.




Public gShowTimestamps As Boolean

now in AddChat---
  ...
  If gShowTimeStamps = True Then
     .SelStart = Len(.Text)
     .SelLength = 0
     .SelColor = Colors(COLOR_TIMESTAMP)     'array or collection of customizable colors
     .SelText = "[" & Format(Time, "HH:MM:SS") & "] "
     .SelStart = Len(.Text)  
  End If
  ...