1369fasihi
New Member
سلام ميشه راجع به شئ ها و كلاس ها در ويژوال برام يه توضيحاتي بدين و بگين چطوري ميشه يك nodepad كامل ايجاد كرد البته يه چيزايي بلدم اما كامل نيست و توضيح بيشتري نياز دارم ازتون به خاطر مباحث جالبتون ممنونم
Name: txtNotes
Left: 0
Top: 0
Multiline: True
ScrollBars: 3-Both
Font: Tahoma , size: 12 , Bold
Private Sub Form_Resize()
txtNotes.Width = frmNotes.ScaleWidth
txtNotes.Height = frmNotes.ScaleHeight
End Sub
Option Explicit
Private Sub Form_Resize()
txtNotes.Width = ScaleWidth
txtNotes.Height = ScaleHeight
End Sub
mnuFile [&File]
… mnuNew [&New]
… mnuSep1 [-]
… mnuOpen [&Open…]
… mnuSave [&Save…]
… mnuSep2 [-]
mnuExit [E&xit]
mnuEdit [&Edit]
… mnuCut [Cu&t]
… mnuCopy [&Copy]
… mnuPaste [&Paste]
… mnuSep3 [-]
… mnuSelAll [Select &All]
mnuHelp [&Help]
… mnuAbout [&About…]
Private Sub mnuNew_Click()
txtNotes.Text = ""
End Sub
Private Sub mnuExit_Click()
Unload Me
End Sub
Private Sub mnuCut_Click()
If txtNotes.SelText <> "" Then
Clipboard.Clear
Clipboard.SetText txtNotes.SelText
txtNotes.SelText = ""
End If
End Sub
Private Sub mnuCopy_Click()
If txtNotes.SelText <> "" Then
Clipboard.Clear
Clipboard.SetText txtNotes.SelText
End If
End Sub
Private Sub mnuPaste_Click()
If Clipboard.GetFormat(vbCFText) = True Then
txtNotes.SelText = Clipboard.GetText(vbCFText)
End If
End Sub
Private Sub mnuSelAll_Click()
If Len(txtNotes.Text) > 0 Then
txtNotes.SelStart = 0
txtNotes.SelLength = Len(txtNotes.Text)
End If
End Sub
Private Sub mnuAbout_Click()
MsgBox "Learning VB6 - MyNotes" & vbNewLine & "PersianTools Forum Topic: http://forum.persiantools.com/showthread.php?t=31711", vbInformation
End Sub
Sub open_file(strFilename As String)
On Error GoTo errs1
Dim f As Integer
Dim tmp As String
f = FreeFile
Open strFilename For Input As #f
tmp = Input(LOF(f), #f)
Close #f
txtNotes.Text = tmp
Exit Sub
errs1:
MsgBox "Error: Can not open file '" & strFilename & "'.", vbExclamation
Close #f
End Sub
Sub save_file(strFilename As String)
On Error GoTo errs1
Dim f As Integer
Dim tmp As String
f = FreeFile
Open strFilename For Output As #f
Print #f, txtNotes.Text
Close #f
MsgBox "File saved successful.", vbInformation
Exit Sub
errs1:
MsgBox "Error: Can not save file '" & strFilename & "'.", vbExclamation
Close #f
End Sub
Name: cdlgDialog
Filter: *.txt|*.txt
Flags: 6
Private Sub mnuOpen_Click()
On Error GoTo errs1
cdlgDialog.CancelError = True
cdlgDialog.ShowOpen
If cdlgDialog.FileName <> "" Then
open_file cdlgDialog.FileName
End If
errs1:
End Sub
Private Sub mnuSave_Click()
On Error GoTo errs1
cdlgDialog.CancelError = True
cdlgDialog.ShowSave
If cdlgDialog.FileName <> "" Then
save_file cdlgDialog.FileName
End If
errs1:
End Sub
Option Explicit
Private Sub Form_Resize()
txtNotes.Width = ScaleWidth
txtNotes.Height = ScaleHeight
End Sub
Private Sub mnuAbout_Click()
MsgBox "Learning VB6 - MyNotes" & vbNewLine & "PersianTools Forum Topic: http://forum.persiantools.com/showthread.php?t=31711", vbInformation
End Sub
Private Sub mnuCut_Click()
If txtNotes.SelText <> "" Then
Clipboard.Clear
Clipboard.SetText txtNotes.SelText
txtNotes.SelText = ""
End If
End Sub
Private Sub mnuCopy_Click()
If txtNotes.SelText <> "" Then
Clipboard.Clear
Clipboard.SetText txtNotes.SelText
End If
End Sub
Private Sub mnuOpen_Click()
On Error GoTo errs1
cdlgDialog.CancelError = True
cdlgDialog.ShowOpen
If cdlgDialog.FileName <> "" Then
open_file cdlgDialog.FileName
End If
errs1:
End Sub
Private Sub mnuSave_Click()
On Error GoTo errs1
cdlgDialog.CancelError = True
cdlgDialog.ShowSave
If cdlgDialog.FileName <> "" Then
save_file cdlgDialog.FileName
End If
errs1:
End Sub
Private Sub mnuPaste_Click()
If Clipboard.GetFormat(vbCFText) = True Then
txtNotes.SelText = Clipboard.GetText(vbCFText)
End If
End Sub
Private Sub mnuSelAll_Click()
If Len(txtNotes.Text) > 0 Then
txtNotes.SelStart = 0
txtNotes.SelLength = Len(txtNotes.Text)
End If
End Sub
Private Sub mnuExit_Click()
Unload Me
End Sub
Private Sub mnuNew_Click()
txtNotes.Text = ""
End Sub
Sub open_file(strFilename As String)
On Error GoTo errs1
Dim f As Integer
Dim tmp As String
f = FreeFile
Open strFilename For Input As #f
tmp = Input(LOF(f), #f)
Close #f
txtNotes.Text = tmp
Exit Sub
errs1:
MsgBox "Error: Can not open file '" & strFilename & "'.", vbExclamation
Close #f
End Sub
Sub save_file(strFilename As String)
On Error GoTo errs1
Dim f As Integer
Dim tmp As String
f = FreeFile
Open strFilename For Output As #f
Print #f, txtNotes.Text
Close #f
MsgBox "File saved successful.", vbInformation
Exit Sub
errs1:
MsgBox "Error: Can not save file '" & strFilename & "'.", vbExclamation
Close #f
End Sub