当前位置:编程学习 > VB >>

关于Winsock1的菜鸟问题

我这有个VB程序  代码都是对的 但是编译的时候说Winsock1.RemoteHost = Text1.Text中.RemoteHost为找到方法或数据成员

   而且所有Winsock1的代码全都显示这样的错误,是因为没有Winsock1这个控件吗,如果没有从哪弄呢,菜鸟初学VB,不懂,还请大牛们多多帮助。

下面是源码

Private Sub Command1_Click()
On Error Resume Next '防止出错,在调试的时候还是不要用这个~
If Text1.Text = "" Or Text2.Text = "" Or Text3.Text = "" Or Text4.Text = "" Or Text5.Text = "" Or Text6.Text = "" Or Text7.Text = "" Then '检查信息的完整性
Call MsgBox("除了备注可以不写,其他信息请填写完全!", 16, "提示")
Else
If Command1.Caption = "发送" Then
Gezi_Tx = Text3.Text   '变量赋值
Gezi_GR = Text4.Text
Gezi_SYS = Text5.Text
Gezi_NA = Text6.Text
Gezi_Ver = Text7.Text
Gezi_BZ = Text8.Text
Gezi_Run  '调用过程
Winsock1.RemoteHost = Text1.Text
Winsock1.RemotePort = Text2.Text
Winsock1.Connect
Else
Winsock1.Close
Command1.Caption = "发送"
Frame2.Enabled = False
End If
End If
End Sub
Private Sub Command2_Click()
  If Text9.Text > 65535 Then '检查端口是否正确
   Call MsgBox("时间在1-65535之间!", 16, "错误")
  Else
  If Command2.Caption = "开始" Then
  Timer3.Interval = Text9.Text
Timer3.Enabled = True
Command2.Caption = "停止"
Text9.Enabled = False
Else
Text9.Enabled = True
Timer3.Enabled = False
Command2.Caption = "开始"
End If
End If
End Sub
Private Sub Form_Load()
Frame2.Enabled = False
End Sub

Private Sub Timer1_Timer()
Dim i, j, a(100) As Integer
For i = 1 To 100
a(i) = Str(i)
Next
Text6 = ""
Randomize '这个是初始化随机数,保证每次生成的都不一样。
For i = 6 To 10
'把Randomize放在这里的话,效率会降低,但是随机性更强。
j = (100 - i) * Rnd + i
a(0) = a(j)
a(j) = a(i)
a(i) = a(0)
Text6 = Text6 & a(i)
Next
End Sub

Private Sub Timer3_Timer()
On Error Resume Next
Winsock1.SendData Gezi_SendIf  '提交信息
End Sub
Private Sub Winsock1_Close()
Frame2.Enabled = False
Label9.Caption = "状态:(未连接)"
Winsock1.Close  '断开连接
Command1.Caption = "上线"
Frame2.Enabled = False
End Sub
Private Sub Winsock1_Connect()
Frame2.Enabled = True
On Error Resume Next
Label9.Caption = "状态:(连接成功,正在发送版本信息)"
Winsock1.SendData Gezi_SendIf   '提交信息
Label9.Caption = "状态:(信息发送完毕)"
Command1.Caption = "断开"
End Sub
Private Sub Winsock1_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
Label9.Caption = "状态:(发送失败)"
Winsock1.Close
End Sub




大牛们帮帮忙,谢谢了 --------------------编程问答-------------------- 工程——〉部件——〉Microsoft Winsock control 6.0 --------------------编程问答--------------------
引用 1 楼 jhone99 的回复:
工程——〉部件——〉Microsoft Winsock control 6.0
--------------------编程问答-------------------- 窗体上有这个控件吗?
或者窗体的Load事件里有加载Winsock1这个控件吗?

有的话,参看楼上~~
补充:VB ,  控件
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,