VB simple Notepad implementation code _VB

Source: Internet
Author: User
Tags chr
Event implementation code:
Copy Code code as follows:

Private Sub Mquit_click ()
Text1.Text = ""
End
End Sub

Private Sub Mnew_click ()
Text1.Text = ""
Form1.caption = "not named"
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 (+) & Chr (10)
Loop
Close #1
Text1.Text = b
End If
End Sub
Private Sub Msave_click ()
If form1.caption = "unnamed" 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

Need to use CommonDialog control!
Property Code:
Copy Code code 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 As
End
Begin VB. Menu Mquit
Caption = "Exit"
Shortcut = ^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.