Valhalla Legends Forums Archive | General Programming | Timestamp help

AuthorMessageTime
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.
March 6, 2003, 10:19 AM
Grok
rtb.SelText = Format(Now, "YYYY-MM-DD HH:MM:SS") & " <" & Name & "> " & MessageText

Like that?
March 6, 2003, 11:38 AM
iago
Doesn't vb have a built-in variable $time?  Or was that QBasic?  I dunno, but try that :)
March 6, 2003, 11:44 AM
MrRaza
[quote]rtb.SelText = Format(Now, "YYYY-MM-DD HH:MM:SS") & " <" & Name & "> " & MessageText

Like that?[/quote]

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


Would that work also.
?
March 6, 2003, 1:22 PM
Spht
[quote]

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


Would that work also.
?[/quote]

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.

[code]'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[/code]

frmMain.rtfChat would of course be your pointer to the RTB control.
March 6, 2003, 1:28 PM
MrRaza
Thanks
March 6, 2003, 2:42 PM
Grok
Expanding on that, add a global boolean to toggle timestamping.




[code]
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
 ...
 
[/code]
March 6, 2003, 3:37 PM

Search