中科因仑“3+1”工程特种兵精英论坛
标题:
用VB实现一个简单的记事本代码
[打印本页]
作者:
还你一世界
时间:
2014-8-9 11:21
标题:
用VB实现一个简单的记事本代码
用VB6实现一个简单的记事本代码,现在公布出实现代码
Private Sub mQuit_Click()
Text1.Text = ""
End
End Sub
Private Sub mNew_Click()
Text1.Text = ""
Form1.Caption = "未命名"
End Sub
Private Sub mopen_Click()
CommonDialog1.ShowOpen
Frame = CommonDialog1.FileName
If fname <> "" Then
Form1.Caption = fname
Text1.Text = ""
Open fname For Input As #1
b = ""
Do Until EOF(1)
Line Input #1, nextline
b = b & nextline & Chr(13) & Chr(10)
Loop
Close #1
Text1.Text = b
End If
End Sub
Private Sub mSave_Click()
If Form1.Caption = "未命名" Or Form1.Caption = "" Then
CommonDialog1.ShowSave
fname = CommonDialog1.FileName
Else
fname = Form1.Caption
End If
If fname <> "" Then
Form1.Caption = fname
Open fname For Output As #1
Print #1, Text1.Text
Close #1
End If
End Sub
Private Sub mNewSave_Click()
CommonDialog1.ShowSave
If fname <> "" Then
Form1.Caption = fname
Open fname For Output As #1
Print #1, Text1.Text
Close #1
End If
End Sub
复制代码
需要用CommonDialog控件,下面是这个控件的代码
Begin VB.Menu mFile
Caption = "文件"
Begin VB.Menu mNew
Caption = "新建"
End
Begin VB.Menu mOpen
Caption = "打开"
End
Begin VB.Menu mSave
Caption = "保存"
End
Begin VB.Menu mNewSave
Caption = "另存为"
End
Begin VB.Menu mQuit
Caption = "退出"
Shortcut = ^E
End
End
复制代码
作者:
还你一世界
时间:
2014-8-11 14:08
自抢沙发!强势顶起!
作者:
墨奚
时间:
2014-8-12 08:47
赞赞赞、。。。。。
作者:
伊海
时间:
2014-8-12 08:56
定制小工具,顶起
欢迎光临 中科因仑“3+1”工程特种兵精英论坛 (http://bbs.enlern.com/)
Powered by Discuz! X3.4