实现上述功能的VB程序如下,但加框处代码有错误,请改正。
Dim a(1 To 15) As Integer
Dim n As Integer 'n为计数器
Dim key As Integer 'key存放筛选条件的数字部分
Dim f As String 'f存放筛选天健的符号部分:大于号或者小于号
Private Sub FormLoad()
Randomize
For i = 1 To 15
a(i) = Int(Rnd * 100)
List1.AddItem Str(a(i))
Next i
End Sub
Private Sub Command1Click()
Dim c As Integer
Dim st As String
n = 0
c = Len(st)
f = Mid(st, 1, 1)
If f = "<" Then Se2 '调用过程
If f = ">" Then Se1 '调用过程
Label2.Caption = "有" + Str(n) + "个筛选结果"
End Sub
Private Sub Se1() '筛选过程1
For i = 1 To 15
If a(i) > key Then
List2.AddItem Str(a(i))
n = n + 1
End If
Next i
End Sub
Private Sub Se2() '筛选过程2
For i = 1 To 15
List2.AddItem Str(a(i))
n = n + 1
End If
Next i
End Sub