vb程序中缺少子程序,函数或属性
发布网友
发布时间:2023-04-28 11:33
我来回答
共2个回答
热心网友
时间:2023-10-28 00:55
这个源代码有2个地方错误:
1、经调试,Picture1.Print a(j).zgh; a(j).xm: a(j).gz错把;打错为:。
2、最多可存放5人的数据,经调试,这个程序只能存储4个数据,打印出来也是4个数据。
经修改后的代码为:
Option Explicit
Private Type zg
zgh As String * 3
xm As String * 3
gz As String * 3
End Type
Dim a(5) As zg, i%
Dim N%
Private Sub command1_click()
i = i + 1
If i > 5 Then MsgBox "最多可存放5人的数据": Exit Sub
With a(i)
.zgh = Val(Text1)
.xm = Text2
.gz = Val(Text3)
End With
Text1 = "": Text2 = "": Text3 = ""
End Sub
Private Sub Command2_Click()
Dim i%, j%, t As zg
For i = 1 To 4
For j = i + 1 To 5
If a(i).gz > a(j).gz Then t = a(i): a(i) = a(j): a(j) = t
Next j
Next i
For j = 1 To 5
Picture1.Print a(j).zgh; a(j).xm; a(j).gz
Next j
End Sub
热心网友
时间:2023-10-28 00:56
三大伽师瓜
热心网友
时间:2023-10-28 00:55
这个源代码有2个地方错误:
1、经调试,Picture1.Print a(j).zgh; a(j).xm: a(j).gz错把;打错为:。
2、最多可存放5人的数据,经调试,这个程序只能存储4个数据,打印出来也是4个数据。
经修改后的代码为:
Option Explicit
Private Type zg
zgh As String * 3
xm As String * 3
gz As String * 3
End Type
Dim a(5) As zg, i%
Dim N%
Private Sub command1_click()
i = i + 1
If i > 5 Then MsgBox "最多可存放5人的数据": Exit Sub
With a(i)
.zgh = Val(Text1)
.xm = Text2
.gz = Val(Text3)
End With
Text1 = "": Text2 = "": Text3 = ""
End Sub
Private Sub Command2_Click()
Dim i%, j%, t As zg
For i = 1 To 4
For j = i + 1 To 5
If a(i).gz > a(j).gz Then t = a(i): a(i) = a(j): a(j) = t
Next j
Next i
For j = 1 To 5
Picture1.Print a(j).zgh; a(j).xm; a(j).gz
Next j
End Sub
热心网友
时间:2023-10-28 00:56
三大伽师瓜