怎么把列表框中的值赋给变量? access vba
PrivateSubCommand3_Click()DimiAsInteger,maxAsInteger,x(1To10)AsIntegeri=0Fori=1To10x(...
Private Sub Command3_Click()
Dim i As Integer, max As Integer, x(1 To 10) As Integer
i = 0
For i = 1 To 10
x(i) = Me!List10
max = x(i)
If max < x(i) Then max = x(i)
Next i
Me.Text4 = max
End Sub
应该怎么写啊……
全部的目前是这样:access2000的程序
Private Sub Command2_Click()
Dim a(1 To 10) As Integer
Dim i As Integer
For i = 1 To 10
a(i) = InputBox("请输入数据")
Me.List10.AddItem a(i)
Next i
End Sub
Private Sub Command3_Click()
Dim i As Integer, max As Integer, x() As Integer
x = Me!List10.list()
For i = 0 To 9
max = x(i)
If max < x(i) Then max = x(i)
Next i
Me.Text4 = max
End Sub 展开
Dim i As Integer, max As Integer, x(1 To 10) As Integer
i = 0
For i = 1 To 10
x(i) = Me!List10
max = x(i)
If max < x(i) Then max = x(i)
Next i
Me.Text4 = max
End Sub
应该怎么写啊……
全部的目前是这样:access2000的程序
Private Sub Command2_Click()
Dim a(1 To 10) As Integer
Dim i As Integer
For i = 1 To 10
a(i) = InputBox("请输入数据")
Me.List10.AddItem a(i)
Next i
End Sub
Private Sub Command3_Click()
Dim i As Integer, max As Integer, x() As Integer
x = Me!List10.list()
For i = 0 To 9
max = x(i)
If max < x(i) Then max = x(i)
Next i
Me.Text4 = max
End Sub 展开
展开全部
变量名=me.列表框名称
这样就可以了
这样就可以了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Sub Command3_Click()
Dim i As Integer, max As Integer
x = Me!List10.List()
For i = 0 To 9
max = x(i, 0)
If max < x(i, 0) Then max = x(i, 0)
Next i
Me.Text4 = max
End Sub
Dim i As Integer, max As Integer
x = Me!List10.List()
For i = 0 To 9
max = x(i, 0)
If max < x(i, 0) Then max = x(i, 0)
Next i
Me.Text4 = max
End Sub
追问
x = Me!List10.list()
没成……用的是access2000
追答
我测试增加的是个1维数组的listbox 看了你的是代码,list10.list()二维的数组.所以不用提前定义x数组.直接把list10.list()赋值给x变量 就可以.
你自己也可以用监视窗口 监视X变量就可以清楚赋值后的X数组结构.
上面的代码我改过了.你试试.如果一定要先定义一个数组再使用的话用下面的代码试试.
Private Sub Command3_Click()
Dim i As Integer, max As Integer, x() As Integer
For n = 0 To UBound(List10.List)
ReDim Preserve x(0 To n)
x(n) =List10.List(n, 0)
Next
For i = 0 To 9
max = x(i)
If max < x(i) Then max = x(i)
Next i
Me.Text4 = max
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询