这个是Visual Basic 程序设计教程(第三版)5.4.3的例题
我照着书上的输入了之后却怎么也运行不出来
有一段 Dim stud(99) As studType
Dim n%
这段我不知道应该放在哪里.后面还有一个stud数组元素我也不知道有什么用.
Private Type studtype
name As String * 5
sex As String * 1
number As Long
department As String * 10
End Type
Private Sub Command1_Click()
If n >= 70 Then
MsgBox ("输入人数超过数组声明的个数")
Else
With stud(n)
.name = Text1
.sex = Text2
.number = Text3
.department = Combo1.Text
End With
Text = "": Text2 = "": Text3 = "":
n = n + 1
End If
.
End Sub
Private Sub Command2_Click()
Dim i%
Picture1.Cls
Picture1.Print "姓名 性别 学号 学院"
Picture1.Print "-----------------------------------"
For i = 0 To n - 1
With stud(i)
Picture1.Print Trim(.name); tap(9); .sex; tap(14); .number; tap(22); .department
End With
Text i
End Sub
Private Sub Command3_Click()
Dim tdepartment As String, i%
Picture2.Cls
tdepartment = InputBox("请输入想要查询的学院")
Picture2.Print "姓名 学院"
For i = 0 To n - 1
If Trim(stud(i).department) = Trim(tdepartment) Then
Picture2.Print stud(i).name, stud(i).department
End If
Next i
End Sub
这是我照着书上输入的代码.With stud(n)显示编译错误,子函数或函数未定义.
本人对VB非常之菜鸟.希望大虾可以详细的教一下,或帮改一下,非常感谢.
= =P.S.我把例题的telephone和school改成了number和department