vb,如何将录入的文本信息保存在另一个窗体中 作业。我编写了一个高考成绩录入系统,前面都是简单的姓名
年龄,高考成绩啊,使用了简单的txt,lab控件,下面命令按钮是录入,如何实现点击录入后将已经输入的姓名等信息保存起来,再点击查看时候可以调出?在线等!...
年龄,高考成绩啊,使用了简单的txt,lab控件,下面命令按钮是录入,如何实现点击录入后将已经输入的姓名等信息保存起来,再点击查看时候可以调出?在线等!
展开
2个回答
展开全部
Dim a()
Dim n As Long
Private Sub Command1_Click()
b = InputBox("请输入要查询同学姓名")
For i = 1 To UBound(a)
If InStr(1, a(i), b) <> 0 Then
MsgBox a(i)
jf = True
Exit For
End If
Next
If jf = False Then MsgBox b & Space(1) & "无该生信息"
jf = False
End Sub
Private Sub Command2_Click()
c = InputBox("请输入 姓名,班级,学号。之间 以 一个空格为分界")
ReDim Preserve a(n + 1)
a(n + 1) = c
n = n + 1
MsgBox "已保存"
End Sub
Private Sub Form_Load()
Open "d:\j.txt" For Input As #1
Do Until EOF(1)
n = n + 1
ReDim Preserve a(n)
Line Input #1, a(n)
Loop
Close
End Sub
Private Sub Form_Unload(Cancel As Integer)
Open "d:\j.txt" For Output As #1
For i = 1 To n
Print #1, a(i)
Next
Close
End Sub
Dim n As Long
Private Sub Command1_Click()
b = InputBox("请输入要查询同学姓名")
For i = 1 To UBound(a)
If InStr(1, a(i), b) <> 0 Then
MsgBox a(i)
jf = True
Exit For
End If
Next
If jf = False Then MsgBox b & Space(1) & "无该生信息"
jf = False
End Sub
Private Sub Command2_Click()
c = InputBox("请输入 姓名,班级,学号。之间 以 一个空格为分界")
ReDim Preserve a(n + 1)
a(n + 1) = c
n = n + 1
MsgBox "已保存"
End Sub
Private Sub Form_Load()
Open "d:\j.txt" For Input As #1
Do Until EOF(1)
n = n + 1
ReDim Preserve a(n)
Line Input #1, a(n)
Loop
Close
End Sub
Private Sub Form_Unload(Cancel As Integer)
Open "d:\j.txt" For Output As #1
For i = 1 To n
Print #1, a(i)
Next
Close
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询