Valhalla Legends Archive

Programming => General Programming => Topic started by: Crypticflare on January 06, 2003, 01:17 PM

Title: Newbie question..but I need assistance
Post by: Crypticflare on January 06, 2003, 01:17 PM
In VB 6.0 I want my RTB to like output a message on startup like "Welcome To Blah Blah" It's not for a bot or anything, I just wanted to play around with it, so I think I need a simple string output. and I don't know how to do that.. any assistance is much appreciated
Title: Re: Newbie question..but I need assistance
Post by: UserLoser on January 06, 2003, 01:24 PM
Public Sub addRTB(ByVal txtOne As String, ByVal clrOne As Long, Optional ByVal txtTwo As String, Optional ByVal clrTwo As Long, Optional ByVal txtThree As String, Optional ByVal clrThree As Long, Optional ByVal txtFour As String, Optional ByVal clrFour As Long, Optional strType As String)
txtOne = Replace(txtOne, vbCrLf, "")
txtTwo = Replace(txtTwo, vbCrLf, "")
txtThree = Replace(txtThree, vbCrLf, "")
txtFour = Replace(txtFour, vbCrLf, "")
Call AddChat(clrOne, txtOne, clrTwo, txtTwo, clrThree, txtThree, clrFour, txtFour)
frmMain.RTB.SelStart = Len(frmMain.RTB.text)
End Sub

Public Sub AddChat(ParamArray saElements() As Variant)
    Dim Data As String

With frmMain.RTB
.SelStart = Len(.text)
.SelLength = 0
.SelColor = vbWhite
.SelStart = Len(.text)
End With
    
Dim i As Integer
For i = LBound(saElements) To UBound(saElements) Step 2
With frmMain.RTB
.SelStart = Len(.text)
.SelLength = 0
.SelColor = saElements(i)
.SelText = saElements(i + 1) & Left$(vbCrLf, -2 * CLng((i + 1) = UBound(saElements)))
.SelStart = Len(.text)
Data = Data & saElements(i + 1)
End With
Next i
End Sub

Example =
on Form_Load()
addRTB "Hello world!", vbRed

- Should work, works for me
Title: Re: Newbie question..but I need assistance
Post by: Crypticflare on January 06, 2003, 01:28 PM
Good Deal, thanks a lot User.
Title: Re: Newbie question..but I need assistance
Post by: UserLoser on January 06, 2003, 01:36 PM
No problem, just msg me on AIM, Yahho, ICQ, if you need any other things and i'll try to help out if im not to busy.
Title: Re: Newbie question..but I need assistance
Post by: Mesiah / haiseM on January 06, 2003, 08:23 PM

Public Sub rtbAdd(MyRichTextBox As RichTextBox, ParamArray saElements() As Variant)
    'This is a nice nice nice way to add colored text to a rich text box
    Dim i As Integer
    For i = LBound(saElements) To UBound(saElements) Step 2
        With MyRichTextBox

        .SelStart = Len(.Text)
    
        .SelLength = 0
        .SelColor = saElements(i)
        .SelText = saElements(i + 1)
    
        .SelStart = Len(.Text)
    
        End With
    Next i

End Sub

call rtbadd vbgreen, "hi my name is: ", vbwhite, "Bob; ", vbcyan, "and i have big boobies" & vbcrlf

the format goes like that as high as you want it.
Title: Re: Newbie question..but I need assistance
Post by: jnem on January 07, 2003, 12:22 PM
"as high as you want it"? Riiight.
Title: Re: Newbie question..but I need assistance
Post by: Zakath on January 08, 2003, 06:54 PM
He means it uses a param array (unspecified number of arguments). You can do the same thing in C by declaring a function with ... as the final parameter.
Title: Re: Newbie question..but I need assistance
Post by: Eibro on January 09, 2003, 09:38 AM
Yes, pass an unlimited amount of arguments...
Until you cause a stack overflow

I think thats what jnem was getting at.
Title: Re: Newbie question..but I need assistance
Post by: Zakath on January 09, 2003, 10:05 AM
Stack corruption is more fun. Sometimes it crashes, sometimes it doesn't. It's like the Wheel of Fortune!
Title: Re: Newbie question..but I need assistance
Post by: Yoni on January 11, 2003, 08:34 AM
And sometimes it can be exploited to run malicious code. :)
Title: Re: Newbie question..but I need assistance
Post by: zraw on January 11, 2003, 10:38 AM
and sometimes we all meet in the mens bathroom, and 'accidently' drop our pants. nobody complains...
Title: Re: Newbie question..but I need assistance
Post by: Yoni on January 11, 2003, 10:40 AM
This is the programming forum - your childhood is off-topic!
Title: Re: Newbie question..but I need assistance
Post by: Banana fanna fo fanna on January 16, 2003, 02:24 PM
LOL warz
Title: Re: Newbie question..but I need assistance
Post by: bin_laden on January 17, 2003, 10:08 PM
Score:

Yoni     Warz
----     ----
 1        0
Title: Re: Newbie question..but I need assistance
Post by: Adron on January 18, 2003, 06:45 AM
Quoteand sometimes we all meet in the mens bathroom, and 'accidently' drop our pants. nobody complains...

Off-topic post; IP of poster banned from forum.
Title: Re: Newbie question..but I need assistance
Post by: Mesiah / haiseM on January 19, 2003, 05:19 PM
bout time, go yoni!