| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 614 人关注过本帖
标题:关于VB通信收发数据程序的问题,请求帮助(使用WINSOCK控件的),谢谢大家
只看楼主 加入收藏
eric_wang
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2006-5-4
收藏
 问题点数:0 回复次数:0 
关于VB通信收发数据程序的问题,请求帮助(使用WINSOCK控件的),谢谢大家
大家好:
我编了个VB 的网络双向通讯程序(通信的另一端是一个具有固定IP的移动终端,IP 和端口我已经在属性里设定了),但是编译时出现错误,错误如下 : THE ADDRESS IS A BROADCAST ADDRESS,AND THE FLAG IS NOT SET.程序如下:(希望高手帮忙,有对这方面比较了解的,麻烦你留言或留下QQ号,不胜感激)
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
---------------------------------------------------------------
搜索更多相关主题的帖子: 收发 WINSOCK 通信 控件 网络 
2006-05-05 22:49
快速回复:关于VB通信收发数据程序的问题,请求帮助(使用WINSOCK控件的),谢谢 ...
数据加载中...
 
   



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

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