(分享)我试着做出记事本的新建。
Private Sub NewFile_Click()Dim FileName$
If RtxtContent.Text = "" Then
RtxtContent.Text = ""
FileName = "无标题 - 记事本"
Me.Caption = FileName
ElseIf RtxtContent.Text <> "" Then
i = MsgBox("文件 " & Me.Caption & " 的文字已经改变。想保存文件吗?", 3 + 48 + 0, 记事本)
If i = vbYes Then
On Error GoTo Errhandler
CommonDialog1.FileName = "*.txt"
CommonDialog1.Filter = "文本文档(*.txt)|*.txt|所有文件|*.*"
CommonDialog1.FilterIndex = 1
CommonDialog1.ShowSave
If CommonDialog1.FileName <> "" Then
Open CommonDialog1.FileName For Output As #1
Print #1, RtxtContent.Text
Close #1
RtxtContent.Text = ""
End If
Errhandler:
Exit Sub
ElseIf i = vbNo Then
Close
RtxtContent.Text = ""
End If
End If
End Sub
[ 本帖最后由 CLT 于 2010-4-3 10:44 编辑 ]