Nasedo
New member
Hay, I have made a network chatting program within Visual Basic 6 and i'm currenly re-writing it in Visual Basic .Net 2008. Im having a problem that i wonder if you could help me with.
When i click the "btnSend" the code below works everytime.
However if i call the code using a keypress function it works only once and fails to do so again. (keypress code below)
Could anyone explain why this is? and maybe offer a solution.
Thanks
Nasedo.
When i click the "btnSend" the code below works everytime.
Private Sub btnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSend.Click
'ADDING DATA TO THE STRINGS
MsgStr = txtMessage.Text & vbCrLf & txtSupportRoom.Text
'OPENS THE SUPPORT ROOM FILE (IF THE FILE CANT BE FOUND IT WILL CREATE IT)
FileOpen(1, SupportRoom, OpenMode.Output)
'WRITES THE DATA WITHIN THE STRING TO THE SUPPORT ROOM FILE
Print(1, MsgStr)
'CLOSES THE SUPPORT ROOM FILE
FileClose(1)
'CLEARS THE MESSAGE TEXTBOX
txtMessage.Text = ""
txtMessage.Focus()
End Sub
However if i call the code using a keypress function it works only once and fails to do so again. (keypress code below)
Private Sub txtMessage_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtMessage.KeyPress
If e.KeyChar = Microsoft.VisualBasic.ChrW(13) Then
Call btnSend_Click(Nothing, Nothing)
End If
End Sub
Could anyone explain why this is? and maybe offer a solution.
Thanks
Nasedo.