Results 1 to 8 of 8

Thread: Raise Event to get value!!! [need ur help, pls help me]

Threaded View

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2005
    Posts
    840

    Question Raise Event to get value!!! [need ur help, pls help me]

    i hv uses the raise event to get the value back to Form A, but there is no expected output display....is it i my way got problem? the receivemessage method is start called from Form A timer

    VB Code:
    1. Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    2.  
    3.         client.ReceiveMessage()
    4. End Sub

    VB Code:
    1. // class method
    2. Public Event displayMessage(ByVal message As String)
    3.  
    4. Public Sub ReceiveMessage()
    5.  
    6.         client.GetStream.BeginRead(rBuffer, 0, rBufferSize, AddressOf read,
    7.          Nothing)
    8.  
    9. End Sub
    10.  
    11. Public Sub read(ByVal dataIn As IAsyncResult)
    12.         Dim ByteRead As Integer
    13.  
    14.         Try
    15.  
    16.             ByteRead = client.GetStream.EndRead(dataIn)
    17.             MsgBox(ByteRead)
    18.             message = Encoding.ASCII.GetString(rBuffer, 0, ByteRead)
    19.             MsgBox(message)
    20.  
    21.             getMessage = True
    22.  
    23.             If getMessage Then
    24.                 RaiseEvent displayMessage(message) //message value is public
    25.             End If
    26.  
    27.         Catch
    28.         End Try
    29.     End Sub

    In Form A:
    VB Code:
    1. Private WithEvents client1 As clientConnect
    2.  
    3. Private Sub loadMessage(ByVal message As System.String) Handles client1.displayMessage
    4.  
    5.         Dim frmMessage As FrmInstantMessage = New FrmInstantMessage
    6.         frmMessage.Show()
    7.         frmMessage.txtMessageList.Text = message & vbCrLf
    8.  
    9.  End Sub
    Last edited by kenny_oh; Aug 30th, 2005 at 10:23 AM.

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