我在以下If评估中收到错误438(对象不支持此属性或方法)。
我已经尝试过“For Each prtr As String”和“For each prtr As Object”
如果我编码“如果doav(i).d1”或“如果doav(i).d42”等,它会很顺利......
d1,d42等是布尔字段
Dim ports As Object = {"d1", "d42", "d123", "d1027", "d1089", "d2109", "lei", "d4130"}
For Each prtr As String In ports
For i As Integer = 0 To A - 1
If doav(i).prtr = True Then
do something
End If
Next
Next
答案 0 :(得分:0)
我相信数组声明就是问题所在。您没有指示端口是一个数组,只是说是一个对象。
Dim ports() As Object = New Object(7) {"d1", "d42", "d123", "d1027", "d1089", "d2109", "lei", "d4130"}
我希望这有效。请让我知道;)
答案 1 :(得分:0)
1-选择严格的选项 2-一次编码并正确调试。 (例如:在做其他事情之前测试你的第一个循环)。
你应该初始化一个字符串数组,而不仅仅是一个对象
Dim ports As String() = {"d1", "d42", "d123", "d1027", "d1089", "d2109", "lei", "d4130"}
For Each prtr As String In ports
Next