帮看一下代码,调试的没问题,编译却提示错误。

china34420 2010-01-08 10:54:12
Dim ClientNum As Integer

Private Sub Command1_Click()
Dim i As Integer

For i = 1 To ClientNum
If Not WSK_Server(i) Is Nothing Then
DoEvents
WSK_Server(i).SendData "服务器:" & Text1.Text
End If
Next
End Sub

Private Sub Form_Load()
WSK_Server(0).LocalPort = 1001
'程序启动时侦听
WSK_Server(0).Listen
End Sub

Private Sub WSK_Server_Close(Index As Integer)
Set WSK_Server(Index) = Nothing
End Sub

Private Sub WSK_Server_ConnectionRequest(Index As Integer, ByVal requestID As Long)
ClientNum = ClientNum + 1
Load WSK_Server(ClientNum) '载入一个新的socket控件

WSK_Server(ClientNum).Accept requestID '接受客户端的请求

WSK_Server(ClientNum).SendData "欢迎光临!!"

End Sub

Private Sub WSK_Server_DataArrival(Index As Integer, ByVal bytesTotal As Long)
Dim myData As String

WSK_Server(Index).GetData myData
Text2.Text = Text2.Text + myData + vbCrLf

End Sub

Private Sub WSK_Server_Error(Index As Integer, 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)
WSK_Server(Index).Close
Set WSK_Server(Index) = Nothing
End Sub


编译时提示属性无效。。。。。。。这是个接授客户端连接的服务器程序,主要是客户端连接时动态添加wskserver(winsock控件),,动态删除
...全文
108 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
yanlongwuhui 2010-01-11
  • 打赏
  • 举报
回复
第一个错误的地方用WSK_Server(Index).Close 替换 Set WSK_Server(Index) = Nothing
第二个错误的地方去掉 Set WSK_Server(Index) = Nothing
liquoryellow 2010-01-09
  • 打赏
  • 举报
回复
VB6中的格式是 Unload WSK_Server(Index) 没有括号。
liquoryellow 2010-01-09
  • 打赏
  • 举报
回复
第二个红色的位置标错地方了。下面那句。
liquoryellow 2010-01-09
  • 打赏
  • 举报
回复
纯VB6的代码,问题出在 Set WSK_Server(Index) = Nothing 这句话了。
出现在两个地方,一个是
Private Sub WSK_Server_Close(Index As Integer)
Set WSK_Server(Index) = Nothing
End Sub
一个是
Private Sub WSK_Server_Error(Index As Integer, 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)
WSK_Server(Index).Close
Set WSK_Server(Index) = Nothing
End Sub
如果你不想再使用WSK_Server(Index)这个控件了,那么不要用set WSK_Server(Index)=nothing
请使用 unload(WSK_Server(Index)),控件是不能被SET nothing的。只能卸载掉。
yanlongwuhui 2010-01-09
  • 打赏
  • 举报
回复
错误提示位置在哪里?
kanliang 2010-01-09
  • 打赏
  • 举报
回复
这是什么 啊。?
qshurufa 2010-01-09
  • 打赏
  • 举报
回复
Dim ClientNum As Integer 赋值了吗?

For i = 1 To ClientNum 好像是这的问题,ClientNum没有赋值,所以循环出错。
zsyok 2010-01-08
  • 打赏
  • 举报
回复
呵呵不懂
go

16,555

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧