我是靠谱客的博主 可爱河马,最近开发中收集的这篇文章主要介绍为什么我用vb编的程序不能运行,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

客户端:
Dim port As Integer
Private Sub Command1_Click()
If Winsock1.State = 7 Then
'Winsock1.Connect
Dim send As String
send = Text2.Text
Winsock1.SendData send
End If
End Sub

Private Sub Form_Load()
Winsock1.Protocol = sckTCPProtocol
Winsock1.LocalPort = 10
Winsock1.RemoteHost = "192.168.1.6"
Winsock1.RemotePort = 10
Winsock1.Connect
End Sub

Private Sub winsock1_DataArrival(ByVal bytesTotal As Long)
Dim s As String
Winsock1.GetData s
Text1.Text = s
End Sub
Private Sub Form_Unload(Cancel As Integer)
Winsock1.Close
End Sub

Private Sub Winsk_ConnectionRequest(Index As Integer, ByVal requestID As Long)
Dim str As String
Dim i As Integer
MsgBox "aaa"
If Index = 0 Then
For i = 0 To max_sessions
With Winsock1
If .State = sckClosed Then
.Accept requestID
Exit For
End If
End With
Next
End If
End Sub
______________________________________________________________________________________
服务端
Private Sub Form_Load()
Winsock1.Protocol = sckTCPProtocol

Winsock1.LocalPort = 10
Winsock1.Listen
End Sub

Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long) '取得数据时发生

Dim Tmp As String

Winsock1.GetData Tmp, vbString '取得数据

Tmp = "对方位址:" + Winsock1.RemoteHostIP + "发言内容为-->" + Tmp

txtmess.Text = Tmp + Chr$(13) + Chr$(10) + txtmess.Text

End Sub

Private Sub Command1_Click()
MsgBox Winsock1.State '发送信息
If Winsock1.State = 7 Then
Winsock1.SendData txtsend.Text
End If
End Sub


 

最后

以上就是可爱河马为你收集整理的为什么我用vb编的程序不能运行的全部内容,希望文章能够帮你解决为什么我用vb编的程序不能运行所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(61)

评论列表共有 0 条评论

立即
投稿
返回
顶部