The form code now : (My menu names are : new,open,save,exit,paste,cut,copy,font => like the caption )
Private Sub copy_Click(Index As Integer)
Clipboard.SetText Text1.SelText
End Sub
Private Sub cut_Click(Index As Integer)
Clipboard.SetText Text1.SelText
Text1.Text = ""
End Sub
Private Sub font_Click(Index As Integer)
With dlg 'open the with dialog
.DialogTitle = "Font" 'set the dialog title
.Flags = cdlCFBoth Or cdlCFEffects 'set the flags so you can
'access the fonts* and the strikethru, underline, color
.ShowFont 'show the dialog
End With
Text1.FontName = dlg.FontName 'set the selected font’s name
Text1.FontSize = dlg.FontSize 'set the selected font’s size
Text1.FontBold = dlg.FontBold 'set the selected font’s bold property
Text1.FontItalic = dlg.FontItalic 'set the selected font’s italic property
Text1.FontStrikethru = dlg.FontStrikethru 'set the selected font’s strikethrough property
Text1.FontUnderline = dlg.FontUnderline 'set the selected font’s underline property
End Sub
Private Sub exit_Click(Index As Integer)
If Text1.Text = "" Then
End
Else
Dim yesnocancel As Integer
yesnocancel = MsgBox("You close the notepad with written text.Do you want to save it?", vbExclamation + vbYesNoCancel, "DBZ-Notepad")
If yesnocancel = vbYes Then
With dlg
.Filter = "Txt Files (*.txt) | *.txt"
.DialogTitle = "Save"
.ShowSave
.CancelError = True
End With
Open dlg.FileName For Append As #1
Print #1, Text1.Text
Close #1
End If
End If
If yesnocancel = vbNo Then
End
End If
If yesnocancel = vbCancel Then
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
If Text1.Text = "" Or Text1.Text = " " Then
End
Else
Dim yesnocancel As Integer
yesnocancel = MsgBox("You close the notepad with written text.Do you want to save it?", vbExclamation + vbYesNoCancel, "DBZ-Notepad")
If yesnocancel = vbYes Then
With dlg
.Filter = "Txt Files (*.txt) | *.txt"
.DialogTitle = "Save"
.ShowSave
.CancelError = True
End With
Open dlg.FileName For Append As #1
Print #1, Text1.Text
Close #1
End If
End If
If yesnocancel = vbNo Then
End
End If
If yesnocancel = vbCancel Then
End If
End Sub
Private Sub new_Click(Index As Integer)
Text1.Text = ""
End Sub
Private Sub open_Click(Index As Integer)
On Error GoTo a:
Dim filelocation As String
With dlg
.ShowOpen
.Filter = "Text Files (*.txt) | *.txt"
.DialogTitle = "Open"
End With
filelocation = dlg.FileName
Text1.Text = ""
Open filelocation For Input As #1
Do Until EOF(1)
Input #1, Data
Text1.Text = Text1.Text + Data + vbNewLine
EOF (1)
Loop
Close #1
a:
End Sub
Private Sub paste_Click(Index As Integer)
Text1.Text = Text1.Text + Clipboard.GetText
End Sub
Private Sub save_Click(Index As Integer)
Dim fnx As String
On Error GoTo a
With dlg
.Filter = "Txt Files (*.txt) | *.txt"
.DialogTitle = "Save"
.ShowSave
End With
Open dlg.FileName For Append As #1
fnx = dlg.FileName
MsgBox "You saved text in : " & fnx, vbInformation, "DBZ-Notepad"
Print #1, Text1.Text
Close #1
a:
End Sub
Private Sub undo_Click(Index As Integer)
If CanUndo(Screen.ActiveControl.hwnd) = True Then
ControlUndo Screen.ActiveControl.hwnd
End If
End Sub
You done. It works.
If u have any questions or suggestions just comment!
Note: The version is bugged because its new ( Like in Open command , Exit (Unload ) and so on. ) So dont tell me about my bugs i kn0w it :P
December 1, 2014 at 5:40 AM
Nice job.But why you not add "Print" features?
Post a Comment