Private Sub cmdsend_Click()
If tcpserver.State <>2 Then
tcpserver.SendData txtsend.Text
txtsend.SetFocus
End If
End Sub
Private Sub Form_Load()
tcpserver.Bind 1000
tcpserver.Listen
End Sub
Private Sub Form_Unload(Cancel As Integer)
tcpserver.Close
End Sub
Private Sub tcpserver_ConnectionRequest(ByVal requestID As Long)
If tcpserver.State <>0 Then
tcpserver.Close
End If
tcpserver.Accept requestID
End Sub
Private Sub tcpserver_DataArrival(ByVal bytesTotal As Long)
Dim getstr As String
tcpserver.GetData getstr, vbString
txtget.Text = getstr &Chr(13) + Chr(10)
End Sub
Private Sub tcpserver_SendComplete()
MsgBox "Send Victory!"
End Sub
Private Sub Timer1_Timer()
lblshowlinkip.Caption = tcpserver.LocalIP
lblshowstatus.Caption = tcpserver.State
End Sub
客服端代码:
Private Sub Form_Load()
tcpclient.Connect
End Sub
Private Sub tcpclient_DataArrival(ByVal bytesTotal As Long)
Dim getstr As String
tcpclient.GetData getstr, vbString
txtget.Text = getstr &Chr(13) + Chr(10)
txtsend.SetFocus
End Sub
Private Sub tcpclient_SendComplete()
MsgBox "Send Victory!"
End Sub
Private Sub Timer1_Timer()
lblshowstatus.Caption = tcpclient.State
lblshowlinkip.Caption = tcpclient.LocalIP
End Sub
注:用的是tcp连接
如果用udp就不一样了
提供一个绘制任意曲线的简单代码。其他功能类似,希望能举一反三。
在窗体中添加一个Picture box,然后输入命令如下:
Dim oldx As SingleDim oldy As Single
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then '当鼠标左建按下时发生
Picture1.Line (oldx, oldy)-(X, Y)
oldx = X
oldy = Y
End If
End Sub
Private Sub Picture1_Mousedown(Button As Integer, Shift As Integer, X As Single, Y As Single)
oldx = X
oldy = Y
End Sub
VB精简板 安装后自动注册直接下载地址 http://www.vdisk.cn/API/fileq.php?id=1369405&cmd=quote&disabletime=1156504186&cercode=728186b1e3a65fdcae8f11bb1105df14
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)