关于BYVAL类型不匹配的问题!

yttlovezxx 2005-11-14 02:22:09
dim porti as long
Private Sub EDSock_SwitchChange(ByVal ConnectID As Long, ByVal PortNum As Long, ByVal Value As Long)
'For PortNum = 1 To 16
PortNum = Porti + 1

'输入端口短路
If Value = 1 And iPhotoIndex(PortNum - 1) = Value Then

' 加载 红灯 显示状态
picinput(PortNum - 1).Picture = LoadPicture("C:\David 's bag\Item\R.bmp")
iPhotoIndex(PortNum - 1) = Value - 1

ElseIf Value = 0 And iPhotoIndex(PortNum - 1) = Value Then
'断路状态
picinput(PortNum - 1).Picture = LoadPicture("C:\David 's bag\Item\Z.bmp")
iPhotoIndex(PortNum - 1) = Value + 1

End If
'Next PortNum

End Sub

运行时提示说类型错误.怎么回事?
...全文
235 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
rainstormmaster 2005-12-07
  • 打赏
  • 举报
回复
// picinput(PortNum - 1).Picture = LoadPicture("C:\David 's bag\Item\R.bmp")

类似这样的代码,前面要加个set,即:
set picinput(PortNum - 1).Picture = LoadPicture("C:\David 's bag\Item\R.bmp")
yttlovezxx 2005-12-06
  • 打赏
  • 举报
回复
楼上的.过程中和过程里有什么区别?
lionking13520 2005-11-14
  • 打赏
  • 举报
回复
Private Sub EDSock_SwitchChange(ByVal ConnectID As Long, ByVal PortNum As Long, ByVal Value As Long)
'For PortNum = 1 To 16
dim porti as long
PortNum = Porti + 1

'输入端口短路
If Value = 1 And iPhotoIndex(PortNum - 1) = Value Then

' 加载 红灯 显示状态
picinput(PortNum - 1).Picture = LoadPicture("C:\David 's bag\Item\R.bmp")
iPhotoIndex(PortNum - 1) = Value - 1

ElseIf Value = 0 And iPhotoIndex(PortNum - 1) = Value Then
'断路状态
picinput(PortNum - 1).Picture = LoadPicture("C:\David 's bag\Item\Z.bmp")
iPhotoIndex(PortNum - 1) = Value + 1

End If
'Next PortNum

End Sub


要把dim porti as long放到过程里去才行
你没把他放到过程中肯定报错,因为没声明
junki 2005-11-14
  • 打赏
  • 举报
回复
变量的定义有没有搞错
或者跟踪调试...
northwolves 2005-11-14
  • 打赏
  • 举报
回复
是不是 iPhotoIndex() 定义成 String 型了?
yttlovezxx 2005-11-14
  • 打赏
  • 举报
回复
这个函数是外部SOCKET控件自带的.只有用这个控件的时候才会调用!

7,762

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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