Valhalla Legends Forums Archive | Visual Basic Programming | AppendRTB Function

AuthorMessageTime
Null
Well , i wrote this a couple of weeks back , maybe some can use it , just a simple "addchat?" type function.

[code]
'Richtext box append text function
'author: effect
Public Function sAppendRTB(ByVal sText As String, ByVal sColor As String, ByVal sFontName As String, ByVal sFontSize As Integer, ByVal sUnderLined As Boolean, ByVal sBold As Boolean, ByVal sItalic As Boolean)

sTimeStamp = "[" & Format(Time, "hh:mm:ss") & "] "

With frmMain.txtOUT
.SelLength = 0
.SelStart = Len(.Text)
.SelFontName = sFontName
.SelFontSize = sFontSize
.SelColor = vbWhite 'timestamp constant color
.SelText = sTimeStamp 'add the timestamp without any text formatting
If sBold = True Then
.SelBold = True 'bold
End If
If sUnderLined = True Then
.SelUnderline = True 'underlined
End If
If sItalic = True Then
.SelItalic = True 'italics
End If
.SelColor = sColor 'text color
.SelText = sText & vbNewLine
End With

End Function
[/code]

Usage:
[code]
Call sAppendRTB(String, Color, Font, FontSize, Underlined, Bold, Italics)
[/code]

Underlined , Bold and Italics are all booleans , [True/False]
May 20, 2004, 1:51 AM
Eli_1
Can I suggest changing your function prototype to:
[code]
Public Function sAppendRTB( _
ByVal sText As String, _
ByVal sColor As ColorConstants, _
Optional sFontName As String = "Times New Roman", _
Optional sFontSize As Integer = 12, _
Optional sUnderLined As Boolean, _
Optional sBold As Boolean, _
Optional sItalic As Boolean)
[/code]

It's just less to type everytime.
[code]
Call sAppendRTB("qwerty" & vbCrLf, vbGreen)
Call sAppendRTB("asdf" & vbCrLf, vbRed, , 14, , True
[/code]
ect...
May 20, 2004, 1:57 AM
LoRd
I suggest using ParamArray() so you can add multiple colors and other text properties to a single line and perhaps adding the ability to choose which RichTextBox you wish to append.
May 20, 2004, 2:01 AM
Eli_1
[quote author=LoRd[nK] link=board=31;threadid=6878;start=0#msg60912 date=1085018500]
I suggest using ParamArray() so you can add multiple colors and other text properties to a single line.
[/quote]

I'm kind of against ParamArray for an addtext function. In most cases it's great, but sometimes it becomes a lot more work.
May 20, 2004, 2:03 AM
LoRd
[quote author=Eli_1 link=board=31;threadid=6878;start=0#msg60913 date=1085018619]
[quote author=LoRd[nK] link=board=31;threadid=6878;start=0#msg60912 date=1085018500]
I suggest using ParamArray() so you can add multiple colors and other text properties to a single line.
[/quote]

I'm kind of against ParamArray for an addtext function. In most cases it's great, but sometimes it becomes a lot more work.
[/quote]
Other than the fact that you have to remember the order in which to add the information in, it's quite a convenience.
May 20, 2004, 2:05 AM

Search