
我试了一个用VB编写的程序,但是运行不出来 但还是就找不出错来,请哪位高手帮一下忙啊
PrivateSubcommmand_click(indexAsInteger)Dimstdu(1To10)Asstdutype,n%,i%,max!,maxi%Sele...
Private Sub commmand_click(index As Integer)
Dim stdu(1 To 10) As stdutype, n%, i%, max!, maxi%
Select Case index
Case 0
If n < 100 Then
n = n + 1
i = n
With stdu(n)
.name = Text1.Text: .special = Text2.Text: .total = Val(Text3.Text)
End With
Text1 = "": Text2 = "": Text3 = ""
Else
MsgBox "输入人数超过声明的个数"
End
End If
Case 1
if i >1Then i = i - 1
With stdu(i)
Text1 = .name: Text2 = .special: Text3 = .total
End With
Case 2
if i < n Then i = i + 1
With stdu(i)
Text1 = .name: Text2 = .special: Text3 = .total
End With
Case 3
max = stdu(1).total
maxi = 1
For j = 2 To n
If stdu(j).total > max Then
max = stdu(j).total
maxii = j
End If
Next j
With stdu(maxi)
Text1 = .name: Text2 = .special: Text3 = .total
End With
i = maxi
End Select
label5 = i & "/" & n
End Sub 展开
Dim stdu(1 To 10) As stdutype, n%, i%, max!, maxi%
Select Case index
Case 0
If n < 100 Then
n = n + 1
i = n
With stdu(n)
.name = Text1.Text: .special = Text2.Text: .total = Val(Text3.Text)
End With
Text1 = "": Text2 = "": Text3 = ""
Else
MsgBox "输入人数超过声明的个数"
End
End If
Case 1
if i >1Then i = i - 1
With stdu(i)
Text1 = .name: Text2 = .special: Text3 = .total
End With
Case 2
if i < n Then i = i + 1
With stdu(i)
Text1 = .name: Text2 = .special: Text3 = .total
End With
Case 3
max = stdu(1).total
maxi = 1
For j = 2 To n
If stdu(j).total > max Then
max = stdu(j).total
maxii = j
End If
Next j
With stdu(maxi)
Text1 = .name: Text2 = .special: Text3 = .total
End With
i = maxi
End Select
label5 = i & "/" & n
End Sub 展开
展开全部
可能存在以下几个问题:
1、commmand_click(index As Integer) 有可能打错了,应该是command1_click(index As Integer)
2、程序中用到n,i等变量,都是局部变量,每次都会初始化为0,所以程序执行有问题。可以把Dim stdu(1 To 10) As stdutype, n%, i%, max!, maxi%
放到窗体变量区
3、Dim stdu(1 To 10) As stdutype只定义了10个元素,但程序里判断了100,应该有错。
1、commmand_click(index As Integer) 有可能打错了,应该是command1_click(index As Integer)
2、程序中用到n,i等变量,都是局部变量,每次都会初始化为0,所以程序执行有问题。可以把Dim stdu(1 To 10) As stdutype, n%, i%, max!, maxi%
放到窗体变量区
3、Dim stdu(1 To 10) As stdutype只定义了10个元素,但程序里判断了100,应该有错。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询