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
PHP Code:Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
client.ReceiveMessage()
End Sub
In Form A:PHP Code:
// class method
Public Event displayMessage(ByVal message As String)
Public Sub ReceiveMessage()
client.GetStream.BeginRead(rBuffer, 0, rBufferSize, AddressOf read,
Nothing)
End Sub
Public Sub read(ByVal dataIn As IAsyncResult)
Dim ByteRead As Integer
Try
ByteRead = client.GetStream.EndRead(dataIn)
MsgBox(ByteRead)
message = Encoding.ASCII.GetString(rBuffer, 0, ByteRead)
MsgBox(message)
getMessage = True
If getMessage Then
RaiseEvent displayMessage(message) //message value is public
End If
Catch
End Try
End Sub
PHP Code:Private WithEvents client1 As clientConnect
Private Sub loadMessage(ByVal message As System.String) Handles client1.displayMessage
[COLOR=DarkRed]Dim frmMessage As FrmInstantMessage = New FrmInstantMessage
frmMessage.Show()
frmMessage.txtMessageList.Text = message & vbCrLf[/COLOR]
End Sub


Reply With Quote


Bookmarks