VB simple notepad implementation code

Source: Internet
Author: User

Event implementation code: Copy codeThe Code is as follows: Private Sub mQuit_Click ()
Text1.Text = ""
End
End Sub

Private Sub mNew_Click ()
Text1.Text = ""
Form1.Caption = "unnamed"
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 = "not named" 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 control is required!
Property Code:Copy codeThe Code is as follows: Begin VB. Menu mFile
Caption = "file"
Begin VB. Menu mNew
Caption = "new"
End
Begin VB. Menu mOpen
Caption = "open"
End
Begin VB. Menu mSave
Caption = "save"
End
Begin VB. Menu mNewSave
Caption = "Save"
End
Begin VB. Menu mQuit
Caption = "quit"
Export cut = ^ E
End
End

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.