Valhalla Legends Archive

Programming => General Programming => Topic started by: MrRaza on March 06, 2003, 04:19 AM

Title: Timestamp help
Post by: MrRaza on March 06, 2003, 04:19 AM
I want to add a timestamp to my rtb along with some text in this fashion.

<timestamp> Name, SentData


Any help would be appreciated.
Title: Re: Timestamp help
Post by: Grok on March 06, 2003, 05:38 AM
rtb.SelText = Format(Now, "YYYY-MM-DD HH:MM:SS") & " <" & Name & "> " & MessageText

Like that?
Title: Re: Timestamp help
Post by: iago on March 06, 2003, 05:44 AM
Doesn't vb have a built-in variable $time?  Or was that QBasic?  I dunno, but try that :)
Title: Re: Timestamp help
Post by: MrRaza on March 06, 2003, 07:22 AM
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.
 ?
Title: Re: Timestamp help
Post by: Spht on March 06, 2003, 07:28 AM
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.
Title: Re: Timestamp help
Post by: MrRaza on March 06, 2003, 08:42 AM
Thanks
Title: Re: Timestamp help
Post by: Grok on March 06, 2003, 09:37 AM
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
  ...