Print #FileNum, Form1.Text1.Text 错在哪?
首先启动vb选择新建EXE文件,在Form1窗体上拉一个TextBox,并把Form1的KeyPreview属性设为True,双击Form1,选择Form的KeyPress事件,输入如下代码: Private Sub Form_KeyPress(KeyAscii As Integer) 'Esc键退出,VbEscape可以用27代替
If KeyAscii = VbEscape Then End
End Sub
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer) '处理Ctrl+X,Shift,Alt+X
If Shift = 2 And KeyCode = vbKeyS Then Print #FileNum, Form1.Text1.Text 'Ctrl+S存盘,VbKeyS=83
If Shift = 1 Then Form1.WindowState = 1 'Shift最小化
If Shift = 4 And KeyCode = vbKeyX Then End 'Alt+X退出,VbkeyX=88
End Sub
Private Sub Form_load()
Dim FileNum As Integer
FileNum = FreeFile
Open App.Path + "\Sample.txt" For Append As #FileNum
End Sub
-----------
“Ctrl+S存盘”这一句有问题,注释这一句可执行。
请高人指点。