vb程序修改

来源:百度知道 编辑:UC知道 时间:2024/06/05 07:54:31
修改源程序,修改后达以下要求
创建班级记录并储存
1.学生人数,班级个数以及班级人数可以修改。
2.学生信息和班级信息用键盘输入。
选做要求:
1.学生信息和班级信息可以通过两个窗体或四个窗体输入输出。
2.输入信息储存在变量上,要求通过数据库或文件储存,达到永久储存。
Private Type studentinfo
intID As Integer '学号
strName As String * 12 '姓名
strSex As String * 2 '性别
End Type

Private Type classinfo
intID As Integer '班号
intNum As Integer '班级人数
student() As studentinfo '班级学生
strClassInfo As String '班级备注信息
End Type
Dim class1 As classinfo

Command1----click
Private Sub Command1_Click()
class1.intNum = InputBox("请输入班级1人数")
ReDim class1.student(class1.intNum + 1) As studentinfo
class1.intID = 1
class1.strClassInfo = "优良学风班"
Command1.Enabled = False
Command2.Enabled = True
End Sub

Private Sub Command2_Click()
Static n As Int

基本程序功能都实现了
就差保存那方面
给一个通用文本读写函数你
Public Function openfile(ByVal filepath As String) As String
Dim s As String
Open filepath For Input As #1
While Not EOF(1)
Line Input #1, sline
s = s & sline & vbCrLf
Wend
Close #1
openfile = s
End Function

Public Function savefile(ByVal filepath As String, ByVal txt As String)
Open filepath For Output As #1
Print #1, txt
Close #1
End Function

读入分行时可以用 split函数