Results 1 to 6 of 6

Thread: Passing a RTB as a Paramater

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2003
    Location
    Eden Prairie Minnesota
    Posts
    301

    Passing a RTB as a Paramater

    I have a Function in a module called Functions

    The function is:

    VB Code:
    1. Public Sub AddChat(ByRef RichTextBox As System.Windows.Forms.RichTextBox, ByVal ParamArray Text() As Object)        With RichTextBox
    2.             .SelectionStart = 99999999
    3.             .SelectionLength = 0
    4.             .SelectionColor = Color.White
    5.             .SelectedText = "[" & TimeOfDay & "] "
    6.             .SelectionLength = 0
    7.         End With
    8.         For I As Byte = LBound(Text) To UBound(Text) Step 2
    9.             With RichTextBox
    10.                 .SelectionStart = 99999999
    11.                 .SelectionLength = 0
    12.                 .SelectionColor = Text(I)
    13.                 .SelectedText = Text(I + 1) & Microsoft.VisualBasic.Left(vbCrLf, -2 * CLng((I + 1) = UBound(Text)))
    14.                 .SelectionStart = 99999999
    15.             End With
    16.         Next
    17.     End Function

    When i try and use this procedure, i can't reference my Rich Text Box

    This is where i call it:

    VB Code:
    1. Public Function Connect(ByVal server As String, ByVal port As Integer) As Boolean
    2.         Dim hostEntry As IPHostEntry = Nothing
    3.  
    4.         hostEntry = Dns.Resolve(server)
    5.  
    6.         Dim address As IPAddress
    7.  
    8.         For Each address In hostEntry.AddressList
    9.             Dim endPoint As New IPEndPoint(address, port)
    10.             Dim tempSocket As New Socket(endPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp)
    11.             Try
    12.                 tempSocket.Connect(endPoint)
    13.             Catch Err As SocketException
    14.                 AddChat(rtbChat, Color.Red, "Error #: " & Err.ErrorCode & ", " & Err.Message)
    15.             End Try
    16.             If tempSocket.Connected Then
    17.                 Socket = tempSocket
    18.                 MsgBox("Connected")
    19.                 Exit For
    20.             End If
    21.         Next address
    22.         Return True
    23.     End Function

    RichTextBox is underlined in blue, with the error "Name 'rtbChat' is not declared.

    Why do i get this? Any help would be GREATLY apreciated

    P.S. Are my functions ok?
    Last edited by BaDDBLooD; Jan 16th, 2005 at 04:09 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width