一个server端
Private Sub Command1_Click()
End
End Sub
Private Sub Command2_Click()
Winsockserver.SendData Text4.Text + ":" + textsend.Text
textget.Text = textget.Text + vbCrLf + Text4.Text + ":" + textsend.Text + " " + Str(Time)
textsend.Text = ""
End Sub
Private Sub Form_Load()
Command2.Visible = False
textsend.Visible = False
Text4.Visible = False
textget.Visible = False
Label1.Visible = False
Winsockserver.LocalPort = 1001
Winsockserver.Listen
End Sub
Private Sub textsend_Change()
'Winsockserver.SendData textsend.text
End Sub
Private Sub textsend_KeyPress(KeyAscii As Integer)
'If KeyAscii = 13 Then
'Winsockserver.SendData textsend.text
'textsend.text = ""
If KeyAscii = 13 Then
Winsockserver.SendData textsend.Text
' Text1.text = Text1.text + vbCrLf + Text4.text + ": " + Text2.text + " " + Str(Time)
textsend.Text = ""
End If
End Sub
Private Sub Timer1_Timer()
If Text4.Text = "" Then Text4.Text = "no name"
End Sub
Private Sub Winsockserver_Close()
Winsockserver.Close
End
End Sub
Private Sub Winsockserver_ConnectionRequest(ByVal requestID As Long)
Command2.Visible = True
textsend.Visible = True
textget.Visible = True
Text4.Visible = True
Label1.Visible = True
If Winsockserver.State <> sckClosed Then Winsockserver.Close
Winsockserver.Accept requestID
End Sub
Private Sub Winsockserver_DataArrival(ByVal bytesTotal As Long)
Dim tmpstr As String
Winsockserver.GetData tmpstr
'textget.text = textget + tmpstr + textsend
textget.Text = textget.Text + vbCrLf + tmpstr + " " + Str(Time)
End Sub
'(1)Command1:退出按钮;
'(2)textsend:发送数据文本框;
'(3)Winsockserver: 服务器Winsock;
'(4)textget :接收数据文本框。
一个clien
发给你 VB的串口调试精灵代码
QQ信箱
请 查收