Public Risp As VbMsgBoxResult, Dis As Boolean
Const Blocco = "Blocco note", NoName = "Senza nome"
Private Sub AzzAll()
AllDx.Checked = False
AllDxxs.Checked = False
AllSx.Checked = False
End Sub
Private Sub AzzCar()
CarGrasso.Checked = False
CarCors.Checked = False
CarSotto.Checked = False
CarSbarra.Checked = False
CarNorm.Checked = False
CarCaratte.Checked = False
End Sub
Private Sub AzzNC()
CarNorm.Checked = False
CarCaratte.Checked = False
End Sub
Private Sub ApriSalva()
dialog.FileName = "*.txt"
dialog.Filter = "*.txt"
End Sub
Private Sub Chiusura()
Risposta = MsgBox("Salvare le modifiche apportate al documento?", vbQuestion + vbYesNoCancel, "Salvare")
If Risp = vbYes Then FlSaveName_Click
If Risp = vbCancel Then Exit Sub
If Risp = vbNo Then End
End Sub
Private Sub DisabilitaMod()
InsOpenAltro.Enabled = Dis
ModCut.Enabled = Dis
ModCopy.Enabled = Dis
ModDel.Enabled = Dis
ModSearch.Enabled = Dis
ModChange.Enabled = Dis
If Clipboard.GetText = "" Then ModPaste.Enabled = Dis
End Sub
Private Sub Nome()
NewName = dialog.FileName
Me.Caption = NewName & " - " & Blocco
End Sub
Private Sub AllDx_Click()
wri.Alignment = 0
AzzAll
AllDx.Checked = True
End Sub
Private Sub AllDxxs_Click()
wri.Alignment = 2
AzzAll
AllDxxs.Checked = True
End Sub
Private Sub AllSx_Click()
wri.Alignment = 1
AzzAll
AllSx.Checked = True
End Sub
Private Sub CarCaratte_Click()
dialog.ShowFont
With wri.Font
.Size = dialog.FontSize
.Name = dialog.FontName
.Bold = dialog.FontBold
.Italic = dialog.FontItalic
.Strikethrough = dialog.FontStrikethru
.Underline = dialog.FontUnderline
End With
AzzCar
CarCaratte.Checked = True
End Sub
Private Sub CarCors_Click()
wri.Font.Italic = Not (wri.Font.Italic)
CarCors.Checked = Not (CarCors.Checked)
AzzNC
End Sub
Private Sub CarGrasso_Click()
wri.Font.Bold = Not (wri.Font.Bold)
CarGrasso.Checked = Not (CarGrasso.Checked)
AzzNC
End Sub
Private Sub CarNorm_Click()
With wri.Font
.Bold = False
.Italic = False
.Strikethrough = False
.Underline = False
End With
AzzCar
CarNorm.Checked = True
End Sub
Private Sub CarSbarra_Click()
wri.Font.Strikethrough = Not (wri.Font.Strikethrough)
CarSbarra.Checked = Not (CarSbarra.Checked)
AzzNC
End Sub
Private Sub CarSotto_Click()
wri.Font.Underline = Not (wri.Font.Underline)
CarSotto.Checked = Not (CarSotto.Checked)
AzzNC
End Sub
Private Sub FlEnd_Click()
If wri.Text = "" Then
End
Else: Chiusura
End If
End Sub
Private Sub FlNew_Click()
If wri.Text <> "" Then
Risposta = MsgBox("Salvare le modifiche apportate al documento?", vbQuestion + vbYesNoCancel, "Salvare")
If Risposta = vbYes Then
FlSave_Click
wri.Text = ""
End If
If Risposta = vbNo Then wri.Text = ""
Else: Exit Sub
End If
FlSave.Enabled = False
Form_Load
Nome
End Sub
Private Sub FlOpen_Click()
On Error Resume Next
wri.Text = ""
InsOpenAltro_Click
FlSave.Enabled = True
InsOpenAltro.Enabled = True
Nome
End Sub
Private Sub FlPrint_Click()
On Error GoTo ferma
dialog.ShowPrinter
With Printer
.ScaleMode = vbMillimeters
.Orientation = dialog.Orientation
.PrintQuality = vbPRPQHigh
With Font
.Name = wri.Font.Name
.Bold = wri.Font.Bold
.Italic = wri.Font.Italic
.Size = wri.Font.Size
.Underline = wri.Font.Underline
.Strikethrough = wri.Font.Strikethrough
End With
End With
Me.PrintForm
Exit Sub
ferma:
MsgBox "Stampa annullata", vbExclamation + vbOKOnly, "Stampa"
End Sub
Private Sub FlSaveName_Click()
On Error Resume Next
ApriSalva
dialog.ShowSave
FileNumber = FreeFile
FlSave_Click
Close #FileNumber
FlSave.Enabled = True
Nome
End Sub
Private Sub FlSave_Click()
FileNumber = FreeFile
Open dialog.FileName & ".txt" For Output As #FileNumber
Print #FileNumber, wri.Text
Close #FileNumber
End Sub
Private Sub Form_Load()
dialog.Flags = cdlCCFullOpen
Me.Caption = NoName & " - " & Blocco
EndSost = False
Dis = False
DisabilitaMod
End Sub
Private Sub Form_Resize()
wri.Width = Me.Width - 120
wri.Height = Me.Height - 800
End Sub
Private Sub Form_Unload(Cancel As Integer)
If wri.Text <> "" Then
Chiusura
If Risposta = vbCancel Then Cancel = 1
End If
End Sub
Private Sub InsDate_Click()
wri.Text = wri & Date
End Sub
Private Sub InsH_Click()
wri.Text = wri & Time
End Sub
Private Sub InsHDate_Click()
wri.Text = wri & Now
End Sub
Private Sub InsOpenAltro_Click()
ApriSalva
dialog.ShowOpen
FileNumber = FreeFile
Open dialog.FileName For Input As FileNumber
Do
Input #FileNumber, linea
wri.Text = wri & linea & vbCrLf
Loop Until EOF(1) = True
Close #FileNumber
End Sub
Private Sub ModChange_Click()
Writer = wri.Text
sostitutivo.Show
If EndSost = True Then wri.Text = Writer
End Sub
Private Sub ModCopy_Click()
Clipboard.SetText (wri.SelText)
End Sub
Private Sub ModCut_Click()
Clipboard.SetText (wri.SelText)
wri.SelText = "" 'pulisce il testo selezionato
End Sub
Private Sub ModDel_Click()
wri.SelText = ""
End Sub
Private Sub ModPaste_Click()
On Error GoTo Err
If Clipboard.GetText <> "" Then
testo1 = Left(wri.Text, wri.SelStart) 'salva i caratteri dall' iniziono del testo fino all' inizio della selezione
testo2 = Right(wri.Text, Len(wri.Text) - wri.SelStart - wri.SelLength) 'salva icaratteri dalla fine deltesto fino allafine della saelezione
wri.Text = testo1 & Clipboard.GetText & testo2
wri.SelStart = Len(testo1) + Len(Clipboard.GetText)
End If
Exit Sub
Err:
MsgBox Err.Number & " " & Err.Description, vbOKOnly
End Sub
Private Sub modSelAll_Click()
wri.SelStart = 0
wri.SelLength = Len(wri.Text)
wri.SetFocus
End Sub
Private Sub wri_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If wri.Text = "" Then Dis = False Else Dis = True
DisabilitaMod
wri.MousePointer = 3
End Sub