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