Jump to content
bc-vnt

Notepad speaker in VB.NET and source code

Recommended Posts

Posted

Download : NotepadSpeaking.exe download - 2shared

Imports System.IO

Public Class Form1
Dim fname As String
Dim fw As StreamWriter
Dim fr As StreamReader
Dim wrap As Boolean = False
Public Shared i As Integer
Public Shared x1, y1, z1 As String
Public Shared m, n As Integer
Dim len As Integer

Private Sub MnOpen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MnOpen.Click
If OpenFileDialog1.ShowDialog = 1 Then
fname = OpenFileDialog1.FileName
Dim fr As New StreamReader(fname)
RTB.Text = fr.ReadToEnd()
fr.Close()
End If
End Sub

Private Sub save()
Dim fw As New StreamWriter(fname)
fw.Write(RTB.Text)
fw.Close()
Dim fr As New StreamReader(fname)
RTB.Text = fr.ReadToEnd()
End Sub

Private Sub MnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MnSave.Click
If fname = "" Then
If SaveFileDialog1.ShowDialog = 1 Then
fname = SaveFileDialog1.FileName
save()
End If
Else
save()
End If
End Sub

Private Sub MnSaveAs_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MnSaveAs.Click
If SaveFileDialog1.ShowDialog = 1 Then
fname = SaveFileDialog1.FileName
save()
End If
End Sub

Private Sub new_f()
Dim fw As New StreamWriter(fname)
fw.Write(RTB.Text)
fw.Close()
End Sub

Private Sub MnNew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MnNew.Click
Dim x As Integer
x = MessageBox.Show("Save", "", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question)
If x = 6 Then
If fname = "" Then
If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
fname = SaveFileDialog1.FileName
new_f()
End If
Else
new_f()
End If
fname = ""
RTB.Text = ""
ElseIf x = 7 Then
If fname <> "" Then
Dim fr As New StreamReader(fname)
fr.Close()
fname = ""
End If
RTB.Text = ""
End If
End Sub

Private Sub MnPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MnPrint.Click
PrintDialog1.Document = PrintDocument1
PrintDialog1.PrinterSettings = PrintDocument1.PrinterSettings
PrintDialog1.AllowSomePages = True
If PrintDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
PrintDocument1.PrinterSettings = PrintDialog1.PrinterSettings
PrintDocument1.Print()
End If
End Sub

Private Sub MnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MnExit.Click
Me.Close()
End Sub

Private Sub MnCut_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MnCut.Click
RTB.Cut()
End Sub

Private Sub MnCopy_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MnCopy.Click
RTB.Copy()
End Sub

Private Sub MnPaste_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MnPaste.Click
RTB.Paste()
End Sub

Private Sub MnUndo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MnUndo.Click
RTB.Undo()
End Sub

Private Sub MnRedo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MnRedo.Click
RTB.Redo()
End Sub

Private Sub MnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MnDelete.Click
RTB.Text = ""
End Sub

Private Sub MnFind_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MnFind.Click
'RTB.Find(InputBox("Enter Characher : "))
y1 = RTB.Text
x1 = InputBox("Find what ")
m = x1.Length
n = y1.Length
len = n - m + 1
For i As Integer = 0 To len
z1 = y1.Substring(i, m)
If z1 = x1 Then
RTB.SelectionStart = i
RTB.SelectionLength = m
Exit For
MessageBox.Show("Found.")
End If
Next
End Sub

Private Sub MnReplace_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MnReplace.Click
'RTB.SelectedText.Replace(InputBox("Enter Old Character : "), InputBox("Enter New Character : "))
End Sub

Private Sub MnSelectAll_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MnSelectAll.Click
RTB.SelectAll()
End Sub

Private Sub MnDeselectAll_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MnDeselectAll.Click
RTB.DeselectAll()
End Sub

Private Sub MnTimeDate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MnTimeDate.Click
RTB.SelectedText = Date.Now
End Sub

Private Sub MnFont_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MnFont.Click
If FontDialog1.ShowDialog = 1 Then
RTB.SelectionFont = FontDialog1.Font
End If
End Sub

Private Sub MnColor_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MnColor.Click
If ColorDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
RTB.SelectionColor = ColorDialog1.Color
End If
End Sub

Private Sub MnSpeaking_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MnSpeaking.Click
Dim speech
speech = CreateObject("sapi.spvoice")
speech.speak(RTB.Text)
End Sub

Private Sub RTB_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RTB.TextChanged
Tcount.Text = "Word Count : " & RTB.Text.Count
TCountLines.Text = "Lines Count : " & RTB.Lines.Count()
End Sub

Private Sub TBackcolor_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TBackcolor.Click
If ColorDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
RTB.BackColor = ColorDialog1.Color
End If
End Sub

Private Sub MnStatusBar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MnStatusBar.Click
If MnStatusBar.Checked = True Then
StatusStrip1.Visible = True
Else
StatusStrip1.Visible = False
End If
End Sub

Private Sub MnAboutNotepad_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MnAboutNotepad.Click
Me.Hide()
AboutBox1.ShowDialog()
End Sub

Private Sub MnWordWrap_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MnWordWrap.Click
If wrap = True Then
MnWordWrap.Checked = False
RTB.WordWrap = False
wrap = False
Else
MnWordWrap.Checked = True
RTB.WordWrap = True
wrap = True
End If
End Sub

Private Sub MnFindNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MnFindNext.Click
RTB.SelectionStart = i
i += 1
If i >= len Then
MessageBox.Show("string not found.")
Else
While i < len
z1 = y1.Substring(i, m)
If z1 = x1 Then
RTB.SelectionStart = i
RTB.SelectionLength = m
Exit While
End If
i += 1
End While
End If
End Sub

Private Sub TNew_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TNew.Click
MnNew_Click(sender, e)
End Sub

Private Sub TOpen_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TOpen.Click
MnOpen_Click(sender, e)
End Sub

Private Sub TSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TSave.Click
MnSave_Click(sender, e)
End Sub

Private Sub TPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TPrint.Click
MnPrint_Click(sender, e)
End Sub

Private Sub TCut_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TCut.Click
MnCut_Click(sender, e)
End Sub

Private Sub TCopy_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TCopy.Click
MnCopy_Click(sender, e)
End Sub

Private Sub TPaste_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TPaste.Click
MnPaste_Click(sender, e)
End Sub

Private Sub TSpeaking_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TSpeaking.Click
MnSpeaking_Click(sender, e)
End Sub
End Class

Scann :

immagine1tc.png

Indication :

immaginezv.png

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...