vb label控件数组 caption 无法赋值 10
我弄了一个有九个元素的Label控件数组,用一个自定义类型从随机文件读入数据,再用循环赋值给CAPTION属性,可Label却一直没变。我通过设断点发现数据读入很正常。本...
我弄了一个有九个元素的Label控件数组,用一个自定义类型从随机文件读入数据,再用循环赋值给CAPTION属性,可Label却一直没变。我通过设断点发现数据读入很正常。本人新手,求助!
Private Sub Inputing()
Open App.Path + "\boxgaming.txt" For Random As 1
a = InputBox("输入关卡号")
If IsNumeric(a) Then
map = a
Get #1, map, data
Else: MsgBox ("请输数字")
End If
Close #1
i(0) = data.d0
i(1) = data.d1
i(2) = data.d2
i(3) = data.d3
i(4) = data.d4
i(5) = data.d5
i(6) = data.d6
i(7) = data.d7
i(8) = data.d8
For k = 0 To 8
Label1(k).Caption = i(k)
Next
End Sub
声明:
Private Type data
d0 As String * 1
d1 As String * 1
d2 As String * 1
d3 As String * 1
d4 As String * 1
d5 As String * 1
d6 As String * 1
d7 As String * 1
d8 As String * 1
End Type
Dim i(8) As String * 1
Dim a As Variant
Dim map As Byte
Dim data As data
注:以下语句却可以赋值
For k = 0 To 8
Label1(k).Caption = “a”
Next
End Sub 展开
Private Sub Inputing()
Open App.Path + "\boxgaming.txt" For Random As 1
a = InputBox("输入关卡号")
If IsNumeric(a) Then
map = a
Get #1, map, data
Else: MsgBox ("请输数字")
End If
Close #1
i(0) = data.d0
i(1) = data.d1
i(2) = data.d2
i(3) = data.d3
i(4) = data.d4
i(5) = data.d5
i(6) = data.d6
i(7) = data.d7
i(8) = data.d8
For k = 0 To 8
Label1(k).Caption = i(k)
Next
End Sub
声明:
Private Type data
d0 As String * 1
d1 As String * 1
d2 As String * 1
d3 As String * 1
d4 As String * 1
d5 As String * 1
d6 As String * 1
d7 As String * 1
d8 As String * 1
End Type
Dim i(8) As String * 1
Dim a As Variant
Dim map As Byte
Dim data As data
注:以下语句却可以赋值
For k = 0 To 8
Label1(k).Caption = “a”
Next
End Sub 展开
2014-08-30
展开全部
i()和data type不要申声为定长看看
追问
试过,不行
追答
监视这里的 i(k),应该能找到原因:
For k = 0 To 8
Label1(k).Caption = i(k)
Next
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询