注册 登录
编程论坛 VB6论坛

VB错误35600

leziyi 发布于 2018-10-28 19:06, 1619 次点击
Public Function AddListView(ListViewName As ListView, Rows As Integer, Columns As Integer, Text As String)

ListViewName.ListItems(Rows).ListSubItems(Columns).Text = Text-------------------------------------此行出错

End Function
2 回复
#2
suzhanpeng2018-12-16 14:39
Public Function AddListView(ListViewName As ListView, Rows As Integer, Columns As Integer, Text As String)

ListViewName.ListItems(Rows).SubItems(Columns) = Text-------------------------------------应该这样吧!

End Function
#3
ZHRXJR2018-12-16 22:20
VB错误35600 是索引超出边界,ListViewName.ListItems(Rows).ListSubItems(Columns).Text = Text
程序代码:
'修改为:
Call AddListView(ListView1, 2, 1, "abcde")     '在过程中调用自定义函数,第一个参数就是 ListView1 控件对象,第二、第三、第四都是随意设置的

Public Function AddListView(ListViewName As ListView, Rows As Integer, Columns As Integer, Text As String)    '自定义函数,定义了四个参数,调用时参数必须一一对应

    ListViewName.ListItems(Rows).ListSubItems(Columns).Text = Text    '这样这些参数均有值,才不会发生错误

End Function

调试没有问题。
1