📄 seepaper.frm
字号:
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "comdlg32.ocx"
Begin VB.Form SeePaper
Caption = "查看试卷"
ClientHeight = 7380
ClientLeft = 60
ClientTop = 345
ClientWidth = 9495
LinkTopic = "Form1"
ScaleHeight = 7380
ScaleWidth = 9495
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton cmdExit
Cancel = -1 'True
Caption = "关闭"
Height = 330
Left = 8100
TabIndex = 2
Top = 7005
Width = 1275
End
Begin VB.CommandButton cmdSave
Caption = "存入文件…"
Default = -1 'True
Height = 330
Left = 6735
TabIndex = 1
Top = 7005
Width = 1275
End
Begin MSComDlg.CommonDialog CommonDialog1
Left = 4560
Top = 3300
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin VB.TextBox txtTest
Height = 6855
Left = 0
MultiLine = -1 'True
ScrollBars = 3 'Both
TabIndex = 0
Top = 0
Width = 9450
End
End
Attribute VB_Name = "SeePaper"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim isSaved As Boolean
Private Sub cmdExit_Click()
Unload Me '关闭窗体
End Sub
Private Sub cmdSave_Click()
Dim fso As New FileSystemObject, fil As TextStream
CommonDialog1.DialogTitle = "选择试卷文件路径/指定文件名"
CommonDialog1.Filter = "试卷文件(*.txt)|*.txt"
CommonDialog1.FileName = App.Path & "\我的试卷.txt"
Do
CommonDialog1.ShowSave
If fso.FileExists(CommonDialog1.FileName) Then
n = MsgBox(CommonDialog1.FileName & vbCrLf & "已存在,是否覆盖该文件?", vbCritical + vbYesNo)
If n = vbYes Then Exit Do
Else
Exit Do
End If
Loop
'将生成的试卷和答案写入文件
Set fil = fso.CreateTextFile(CommonDialog1.FileName)
fil.WriteLine txtTest
fil.Close
MsgBox "试卷已成功保存到<" & CommonDialog1.FileName & ">中!", vbInformation
isSaved = True
End Sub
Private Sub Form_Resize()
txtTest.Width = Abs(Me.Width - 100)
txtTest.Height = Abs(Me.Height - 900)
cmdSave.Top = txtTest.Height + 100
cmdExit.Top = cmdSave.Top
cmdExit.Left = Abs(Me.Width - cmdExit.Width - 200)
cmdSave.Left = Abs(cmdExit.Left - cmdSave.Width - 100)
End Sub
Private Sub Form_Unload(Cancel As Integer)
Dim fso As New FileSystemObject, fil As TextStream
If Not isSaved Then
n = MsgBox("试卷还没有保存,是否保存?", vbCritical + vbYesNo)
If n = vbYes Then
CommonDialog1.DialogTitle = "选择试卷文件路径/指定文件名"
CommonDialog1.Filter = "试卷文件(*.txt)|*.txt"
CommonDialog1.FileName = App.Path & "\我的试卷.txt"
Do
CommonDialog1.ShowSave
If fso.FileExists(CommonDialog1.FileName) Then
n = MsgBox(CommonDialog1.FileName & vbCrLf & "已存在,是否覆盖该文件?", vbCritical + vbYesNo)
If n = vbYes Then Exit Do
Else
Exit Do
End If
Loop
'将生成的试卷和答案写入文件
Set fil = fso.CreateTextFile(CommonDialog1.FileName)
fil.WriteLine txtTest
fil.Close
MsgBox "试卷已成功保存到<" & CommonDialog1.FileName & ">中!", vbInformation
End If
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -