I have a Function in a module called Functions
The function is:
VB Code:
Public Sub AddChat(ByRef RichTextBox As System.Windows.Forms.RichTextBox, ByVal ParamArray Text() As Object) With RichTextBox .SelectionStart = 99999999 .SelectionLength = 0 .SelectionColor = Color.White .SelectedText = "[" & TimeOfDay & "] " .SelectionLength = 0 End With For I As Byte = LBound(Text) To UBound(Text) 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
When i try and use this procedure, i can't reference my Rich Text Box
This is where i call it:
VB Code:
Public Function Connect(ByVal server As String, ByVal port As Integer) As Boolean Dim hostEntry As IPHostEntry = Nothing hostEntry = Dns.Resolve(server) Dim address As IPAddress For Each address In hostEntry.AddressList Dim endPoint As New IPEndPoint(address, port) Dim tempSocket As New Socket(endPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp) Try tempSocket.Connect(endPoint) Catch Err As SocketException AddChat(rtbChat, Color.Red, "Error #: " & Err.ErrorCode & ", " & Err.Message) End Try If tempSocket.Connected Then Socket = tempSocket MsgBox("Connected") Exit For End If Next address Return True 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?




Reply With Quote