vb 二维数组 index 下标越界
PrivateSubCommand2_Click()IfCombo1.Text=""ThenMsgBox"请先选择课程名!!!",vbOKOnly,"信息提示!"EndI...
Private Sub Command2_Click()
If Combo1.Text = "" Then
MsgBox "请先选择课程名!!!", vbOKOnly, "信息提示!"
End If
'将上次所录入的“平时成绩”和“考试成绩”显示在相应的对话框中
If Combo1.Text = "vb程序设计" Then
arrStInfo(Index, 13) = Text1.Text
arrStInfo(Index, 14) = Text2.Text
End If
If Combo1.Text = "c程序设计" Then
arrStInfo(Index, 15) = Text1.Text
arrStInfo(Index, 16) = Text2.Text
End If
Index = Index - 1
'对最后一条信息做冗错处理
If Index > UBound(arrStInfo) Then
MsgBox "已经是最后一条记录了!!!"
Index = UBound(arrStInfo)
If Combo1.Text = "vb程序设计" Then
Text1.Text = arrStInfo(Index, 13)
Text2.Text = arrStInfo(Index, 14)
Label7.Caption = arrStInfo(Index, 12)
End If
If Combo1.Text = "c程序设计" Then
Text1.Text = arrStInfo(Index, 15)
Text2.Text = arrStInfo(Index, 16)
Label7.Caption = arrStInfo(Index, 17)
End If
Else
Label6.Caption = arrStInfo(Index, 1)
If Combo1.Text = "vb程序设计" Then
Text1.Text = arrStInfo(Index, 13)
Text2.Text = arrStInfo(Index, 14)
Label7.Caption = arrStInfo(Index, 12)
End If
If Combo1.Text = "c程序设计" Then
Text1.Text = arrStInfo(Index, 15)
Text2.Text = arrStInfo(Index, 16)
Label7.Caption = arrStInfo(Index, 17)
End If
End If
End Sub
Private Sub Form_Load()
'为初始时的“姓名”赋初值
Label6.Caption = arrStInfo(Index, 1)
'为课程名赋初值
Combo1.AddItem "vb程序设计"
Combo1.AddItem "c程序设计"
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii < Asc("0") And KeyAscii <> 8 Then
Text1.Locked = True
MsgBox "输入的数据为非数值型数据,请重新输入", vbExclamation + vbOKOnly, "错误"
ElseIf KeyAscii > Asc("9") Then
Text1.Locked = True
MsgBox "输入的数据为非数值型数据,请重新输入", vbExclamation + vbOKOnly, "错误"
Else
Text1.Locked = False
End If
End Sub 展开
If Combo1.Text = "" Then
MsgBox "请先选择课程名!!!", vbOKOnly, "信息提示!"
End If
'将上次所录入的“平时成绩”和“考试成绩”显示在相应的对话框中
If Combo1.Text = "vb程序设计" Then
arrStInfo(Index, 13) = Text1.Text
arrStInfo(Index, 14) = Text2.Text
End If
If Combo1.Text = "c程序设计" Then
arrStInfo(Index, 15) = Text1.Text
arrStInfo(Index, 16) = Text2.Text
End If
Index = Index - 1
'对最后一条信息做冗错处理
If Index > UBound(arrStInfo) Then
MsgBox "已经是最后一条记录了!!!"
Index = UBound(arrStInfo)
If Combo1.Text = "vb程序设计" Then
Text1.Text = arrStInfo(Index, 13)
Text2.Text = arrStInfo(Index, 14)
Label7.Caption = arrStInfo(Index, 12)
End If
If Combo1.Text = "c程序设计" Then
Text1.Text = arrStInfo(Index, 15)
Text2.Text = arrStInfo(Index, 16)
Label7.Caption = arrStInfo(Index, 17)
End If
Else
Label6.Caption = arrStInfo(Index, 1)
If Combo1.Text = "vb程序设计" Then
Text1.Text = arrStInfo(Index, 13)
Text2.Text = arrStInfo(Index, 14)
Label7.Caption = arrStInfo(Index, 12)
End If
If Combo1.Text = "c程序设计" Then
Text1.Text = arrStInfo(Index, 15)
Text2.Text = arrStInfo(Index, 16)
Label7.Caption = arrStInfo(Index, 17)
End If
End If
End Sub
Private Sub Form_Load()
'为初始时的“姓名”赋初值
Label6.Caption = arrStInfo(Index, 1)
'为课程名赋初值
Combo1.AddItem "vb程序设计"
Combo1.AddItem "c程序设计"
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii < Asc("0") And KeyAscii <> 8 Then
Text1.Locked = True
MsgBox "输入的数据为非数值型数据,请重新输入", vbExclamation + vbOKOnly, "错误"
ElseIf KeyAscii > Asc("9") Then
Text1.Locked = True
MsgBox "输入的数据为非数值型数据,请重新输入", vbExclamation + vbOKOnly, "错误"
Else
Text1.Locked = False
End If
End Sub 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询