VB中按键出发的条件语句

来源:百度知道 编辑:UC知道 时间:2024/05/25 03:53:21
VB中按键出发的条件语句和想保存使用者在程序内输入的数据该怎么做(再次打开数据还在)
讲详细点
按键触发,keypress哪个
如何写入文件,打开时读出
1指代什么 要求更加详细

Private Sub Form_KeyPress(KeyAscii As Integer)
Case KeyAscii
'自己的内容******
End
End Sub

写入文件,打开时读出。 1是指文件号码。
Open "a.txt" For Output As 1
'写入 例如write#1,text1.text,label1.caption
Close 1

Open "a.txt" For Input As 1
'读出 例如read#1,text1.text,label1.caption
Close 1
注意读出和写入要一致!

下面是简单的例子:
Option Explicit

Private Sub Form_DblClick()
Open "c:\s.txt" For Output As #1
Write #1, Text1.Text
Close #1
End Sub

Private Sub Form_Load()
Dim s
On Error Resume Next
Open "c:\s.txt" For Input As #1
Input #1, s: Text1.Text = s
Close #1
On Error GoTo 0
End Sub