Valhalla Legends Archive

Programming => General Programming => .NET Platform => Topic started by: BaDDBLooD on June 27, 2004, 01:20 PM

Title: How do you do this?
Post by: BaDDBLooD on June 27, 2004, 01:20 PM
I have AddChat on my Main Form

Than in a Class Module

i want to use addchat

So i do



frmMain.AddChat(rtbChat, Color.Yellow, "BNLS: Sending Authorization")



It says name "rtbChat" is not declared

As a test i did

frmMain.rtbChat instead of rtbChat, and than frmMain.AddChat got the same error.

Note: The Addchat works if i use it on the same form it's located.



   Public Function AddChat(ByVal RichTextBox As RichTextBox, ByVal ParamArray Text() As Object) As Object

       With RichTextBox
           .SelectionStart = 99999999
           .SelectionLength = 0
           .SelectionColor = Color.White
           .SelectedText = "[" & TimeOfDay & "] "
           .SelectionStart = 99999999
       End With

       For I As Integer = Text.GetLowerBound(0) To Text.GetUpperBound(0) Step 2

           With RichTextBox
               .SelectionStart = 99999999
               .SelectionLength = 0
               .SelectionColor = Text(I)
               .SelectedText = Text(I + 1) & Microsoft.VisualBasic.Left(vbCrLf, -2 * CLng((I + 1) = UBound(Text)))
               .SelectionStart = 99999999
           End With

       Next

   End Function



Bare with me.. I am still learning .NET and i don't have a Good Book, and haven't found a really nice tutorial site for vb.net ( yet )
Title: Re:How do you do this?
Post by: ChR0NiC on June 27, 2004, 03:52 PM
Quote from: BaDDBLooD on June 27, 2004, 01:20 PM
Bare with me.. I am still learning .NET and i don't have a Good Book, and haven't found a really nice tutorial site for vb.net ( yet )

No offense, but any good bot writer will tell you to learn the language before attempting to make a bot. This instance is  no different.
Title: Re:How do you do this?
Post by: warz on June 27, 2004, 03:56 PM
I wouldnt tell you that. I'm a fan of learning from examples. Books don't do it for me.
Title: Re:How do you do this?
Post by: BaDDBLooD on June 27, 2004, 03:57 PM
Same here warz =)

Anyone got any help?
Title: Re:How do you do this?
Post by: MyndFyre on June 27, 2004, 07:49 PM
Quote from: warz on June 27, 2004, 03:56 PM
I wouldnt tell you that. I'm a fan of learning from examples. Books don't do it for me.

Then learn by examples, don't learn by code.  The .NET Framework SDK Documentation has more samples than the number of men your momma has slept with.  (Cheesy, I know).  So look at the samples.  This isn't time for us to do for you.
Title: Re:How do you do this?
Post by: BaDDBLooD on June 27, 2004, 09:08 PM
Quote from: Myndfyre on June 27, 2004, 07:49 PM
Quote from: warz on June 27, 2004, 03:56 PM
I wouldnt tell you that. I'm a fan of learning from examples. Books don't do it for me.

Then learn by examples, don't learn by code.  The .NET Framework SDK Documentation has more samples than the number of men your momma has slept with.  (Cheesy, I know).  So look at the samples.  This isn't time for us to do for you.

Got any advice on how to do this MyndFyre? I been looking over Google.. but have found nothing on how to fix my problem.
Title: Re:How do you do this?
Post by: MyndFyre on June 28, 2004, 01:19 AM
What I would suggest is this....

The RichTextBox rtbChat belongs to an instance of frmMain.  If all the work you're doing is on frmMain, then from within frmMain, all you have to do is AddChat(ByVal ParamArray data() As Object).  You don't need to use ByVal rtbChat As RichTextBox.  Why?  Because the AddChat function already knows what RTB to add to -- the one on its form.
Title: Re:How do you do this?
Post by: BaDDBLooD on June 28, 2004, 11:13 AM
i have 2 ;\
Title: Re:How do you do this?
Post by: MyndFyre on June 28, 2004, 12:25 PM
By the way, you don't use frmMain.AddChat unless frmMain is static (which it is not, it's instance).  You have an INSTANCE of frmMain, such as:


Sub DoSomething(ByVal fm As frmMain)

End Sub


And within that function, you can do


fm.AddChat( argument-list )