| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 599 人关注过本帖
标题:vb通信程序问题(关于WINNSOCK控件的)
只看楼主 加入收藏
eric_wang
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2006-5-4
收藏
 问题点数:0 回复次数:2 
vb通信程序问题(关于WINNSOCK控件的)
我编了个VB 的网络双向通讯程序,但是编译时出现错误,错误如下 : THE ADDRESS IS A BROADCAST ADDRESS,AND THE FLAG IS NOT SET.程序如下:(希望高手帮忙,IP 和端口我已经在属性里设定了)
Private Sub Form_Load()
Dim ConnectFlag As Boolean '设置判断是否连接标志
ConnectFlag = False
End Sub
-----------------------------------------------------------------------------------------------------------------------------
Private Sub Winsock1_Close()
Winsock1.Close
Do
DoEvents
Loop Until Winsock1.State = sckClosed
ConnectFlag = False
End Sub
-----------------------------------------------------------------------------------------------------------------------------
Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)
If Not ConnectFlag Then
Winsock1.Close
Winsock1.Connect
Do
DoEvents
Loop Until Winsock1.State = sckConnected
ConnectFlag = True
End Sub
-----------------------------------------------------------------------------------------------------------------------------
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim datastr As String '存储传输过来的数据
Winsock1.GetData datastr
var1 = Mid(datastr, 17, 24)'将数据存入数据库
var2 = Mid(datastr, 25, 32)
var3 = Mid(datastr, 33, 40)
var4 = Mid(datastr, 41, 48)
var5 = Mid(datastr, 49, 56)
var6 = Mid(datastr, 57, 64)
var7 = Mid(datastr, 65, 72)
var8 = Mid(datastr, 73, 80)
da1.Text = var1
da2.Text = var2
da3.Text = var3
da4.Text = var4
da5.Text = var5
da6.Text = var6
da7.Text = var7
da8.Text = var8
Data1.Recordset.AddNew
Data1.UpdateRecord
Data1.Recordset.Bookmark = Data1.Recordset.LastModified
Data1.Refresh
end sub
-----------------------------------------------------------------------------------------------------------------------------
Private Sub xpcmdbutton1_Click() '发送数据的指令
Dim cmdstr1 As String
cmdstr1 = "00" '发送命令"00"
Winsock1.Connect
Winsock1.SendData cmdstr1
End Sub
---------------------------------------------------------------
搜索更多相关主题的帖子: 控件 WINNSOCK 通信 
2006-05-04 08:51
风沙雪雨
Rank: 1
等 级:新手上路
帖 子:43
专家分:0
注 册:2006-5-4
收藏
得分:0 
全源码?
2006-05-04 21:07
eric_wang
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2006-5-4
收藏
得分:0 

是通信部分源码,我想做的是计算机与一个具有固定IP的移动终端的数据通信,所以只需要做计算机这部分的程序,请帮帮忙

2006-05-05 08:46
快速回复:vb通信程序问题(关于WINNSOCK控件的)
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.024852 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved