vb错误 424 要求对象 在线等答案~~拜托了~

来源:百度知道 编辑:UC知道 时间:2024/06/21 14:50:08
Dim score As Variant

Private Sub Form_Load()

Label1.Caption = " 查找最高低分"
score = Array(89, 86, 81, 67, 90)
End Sub
Private Sub Command1_Click()
Dim max As Integer
Dim min As Integer
max = score(1)
min = score(1)
For i = 2 To 5
If max < score(i) Then
max = score(i)
End If
If min > score(i) Then
min = score(i)
End If
Next i
Label1.Caption = "zuigaofen:" + Str(max) + Chr(13) + "zuidifen:" + Str(min)
End Sub

确保你的窗体上有 lable1控件 和 command1 控件

Dim score As Variant

Private Sub Form_Load()

Label1.Caption = " 查找最高低分"
score = Array(89, 86, 81, 67, 90)
End Sub
Private Sub Command1_Click()
Dim max As Integer
Dim min As Integer
max = score(1)
min = score(1)
For i = 2 To 5
If max < score(i - 1) Then '数组的默认下标是从0开始 第五个素 因该是 score(4)
max = score(i - 1)
End If
If min > score(i - 1) Then
min = score(i - 1)
End If
Next i
Label1.Caption = "zuigaofen:" + Str(max) + Chr(13) + "zuidifen:" + Str(min)
End Sub

1.在窗体上添加标签(Label)控件,在属性窗口中将其命名为Label1
2.将For i = 2 To 5
改为
For i = 0 To 4
3.运行即可

你的 窗体上 有没有 Label1 呢?