关于VBA编程在Access的操作
随机数降序排序窗体视图
随机数降序排序效果图 展开
假定两个文本框分别为 text3 和 text5,各按钮代码分别如下:(详见附件)
Private Sub Command10_Click() '清除
Me.Text3 = ""
Me.Text5 = ""
End Sub
Private Sub Command8_Click() '产生随机序列
Dim I%, S$
For I = 1 To 6
S = S & Int(100 + 899 * Rnd()) & " "
Next
Text3 = Trim(S)
End Sub
Private Sub Command9_Click() '排序
Dim I%, J%, Tem%, S$
Arr = Split(Text3)
For I = 0 To 4
For J = I + 1 To 5
If Val(Arr(I)) < Val(Arr(J)) Then
Tem = Arr(I)
Arr(I) = Arr(J)
Arr(J) = Tem
End If
Next
S = S & Arr(I) & " "
Next
Text5 = S & Arr(5)
End Sub