Jul 11, 2011 11:13 AM
(This post was last modified: Jul 11, 2011 11:13 AM by Skillful.)
Hello guys,
Here I present my first tutorial!!
In this tutorial I am going to teach you how to make an advanced text editor!!! :D
Hope you like it!!! :D cooll;
1. First open up VB.NET and create a new Windows Forms project with framework version 3.00.
2. After the project loads edit Form 1's these properties -
Size - 864, 659
StartPosition - CenterScreen
Text - Advanced Text Editor
3. Then drag a Menustrip, OpenFileDialog and SaveFileDialog onto the Form and then create menu items in the same order as that in this screen shot -
[img]http://farm6.static.flickr.com/5007/5303620235_e74def2012_z.jpg[/img]
4. Now add sub items under the file menu item in the same order as given below-
Open
Save
Save As
New
Exit
5. Now add sub items under the Font menu item in the same order as given below-
Font Type
Font Style (add sub items under this in the same order as given- Bold,Underline,Italic,Strikeout)
Font Color
Convert Case (add sub items under this in the same order as given- To UPPER,To lower)
6. Now add sub items under the Page menu item in the same order as given below-
Page Color
7. Now add sub items under the Text Alignment menu item in the same order as given below-
Left
Center
Right
8. Now add sub items under the Indent menu item in the same order as given below-
+1
-1
9. Now add sub items under the Bullets menu item in the same order as given below-
Add
Remove
10. Now add sub items under the Find & Replace menu item in the same order as given below-
Find
Replace
Find & Replace
11. Now add sub items under the Insert menu item in the same order as given below-
Image
12. Now add sub items under the Zoom menu item in the same order as given below-
In
Out
13. Now add sub items under the Undo & Redo menu item in the same order as given below-
Undo
Redo
14. Now add sub items under the Clipboard menu item in the same order as given below-
Copy
Cut
Paste
Select All Text
Erase All Text
15. Now add sub items under the View In menu item in the same order as given below-
Web Browser
16. Now add sub items under the Text Reader menu item in the same order as given below-
Selected Text
Full Document
Settings
Stop Speaking
17. Drag a Status strip on to the form and create Tool strip status labels in the same order as in the screen shot above.
18. Drag 5 labels from the toolbox on to the status strip and change these properties-
Visible = False
19. Change Label5's text property to 50 and Label4's text property to 0.
20. Drag a Rich text box from the toolbox on to the form and change these properties of it-
Dock - Fill
21. Now click on the VB.NET menu item called Project and then select Add Reference. Then go to the .NET tab and then search for System.Speech. Once you find it, select it and then click OK.
22. Now right click anywhere on the form and then click on view code and paste this code above Public Class Form1-
And this below Public Class Form1
23. Double click on the Open menu item under the File menu item of the menustrip on the form and add this code to it-
24. Similarly double click on the Save menu item and add this code to it-
25. Now double click on the Save As menu item and add this code to it-
26. Double Click on the New menu item and add this code to it-
27. Double click on the Exit menu sub item under File and add this code to it-
28. Double click on Font Type menu item and add this code to it-
29. Double Click on the Bold menu sub item under Font-->Font Styles and add this code to it-
30. Double Click on the Underlinemenu sub item under Font-->Font Styles and add this code to it-
31. Double Click on the Italic menu sub item under Font-->Font Styles and add this code to it-
32. Double Click on the Strikeout menu sub item under Font-->Font Styles and add this code to it-
33. Double Click on the Font Color menu sub item under Font and add this code to it-
34. Double click on the Page Color menu sub item under Page and add this code to it-
35. Double click on the Left menu sub item under Text Alignment and add this code to it-
36. Double click on the Center menu sub item under Text Alignment and add this code it-
37. Double click on the Right menu sub item under Text Alignment and add this code to it-
38. Double click on the +1 menu sub item under Indent and add this code to it-
39. Double click on the -1 menu sub item under Indent and add this code to it-
40. Double click on the Add menu sub item under Bullets and add this code to it-
41. Double click on the Remove menu sub item under Bullets and add this code to it-
42. Double click on the Image menu sub item under Image and add this code it-
43. Double click on the In menu sub item under Zoom and add this code to it-
44. Double click on the Out menu sub item under Zoom and add this code to it-
45. Double click on the Undo menu sub item under Undo & Redo and add this code to it-
46. Double click on the Redo menu sub item under Undo & Redo and add this code it-
47. Double click on the Copy sub menu item under Clipboard and add this code to it-
48. Double click on the Cut sub menu item under Clipboard and add this code to it-
49. Double click on the Paste menu sub item under Clipboard and add this code to it-
50. Double click on the Select All Text menu sub item under Clipboard and add this code it-
51. Double click on the Erase All Text menu sub item under Clipboard and add this code to it-
52. Double click on the Web Browser menu sub item under View In and add this code to it-
53. Now add a new form to your project by clicking the VB.NET menustrip--> Project-->Add Windows Form and then name it Form2 and change its these properties-
FormBorderStyle - FixedSingle
MaximizeBox - False
Size - 343,183
Text - Find & Replace
54. Add 2 labels, 2 Text boxes, 1 check box, 4 buttons on to the form and change its these properties-
Label1
Location - 3,9
Text - Find What
TextBox1
Location - 6,25
Size - 319,20
Label2
Location - 3,58
Text - Replace With
TextBox2
Location - 6,74
Size - 319,20
Button1
Location - 6,124
Size - 75,23
Text - Find
Button2
Location - 87, 124
Size - 75,23
Text - Find Next
Button3
Location - 168,124
Size - 75,23
Text - Replace
Button4
Location - 249,124
Size - 75,23
Text - Replace All
CheckBox1
Location - 6,101
Text - Match Case
55. Double click on the Find button and add this code to it-
56. Double click on the Find Next button and paste this code-
57. Double click on the Replace button and add this code to it-
58. Double click on the Replace All button and add this code to it-
59. Create one more new form by clicking on VB.NET menu item called Project-->Add Windows Form and name the form Form3 and change these properties of it-
FormBorderStyle - FixedSingle
MaximizeBox - False
Size - 283, 106
Text - Find
60. Drag 1 label, 1 Textbox, 1 check box and 2 buttons on to the form and change its these properties-
Label1
Location - 3,9
Text - Find What
TextBox1
Location - 6,26
Size - 259,20
CheckBox1
Location - 6,53
Text - Match Case
Button1
Location - 109,47
Size - 75,23
Text - Find
Button2
Location - 190,47
Size - 75,23
Text - Find Next
61. Double click on the Find button on the Form and add this code to it-
62. Double click on the Find Next button on the Form and add this code to its-
63. Create a new Windows Form by clicking on the VB.NET menu item called Project-->Add Windows Form and then name it Form4.vb and then its these properties-
FormBorderStyle - FixedSingle
MaximizeBox - False
Size - 285,157
Text - Text Reader Settings
64. Drag 3 labels, 2 trackbars and 1 combo box from the toolbox on to the form and change its these properties-
Label1
Location - 3,17
Text - Select Voice :
Label2
Location - 12,50
Text - Speed :
Label3
Location - 12,91
Text - Volume
ComboBox1
Location - 76,14
Size - 191,21
Text - Microsoft Anna
TrackBar1
Location - 76,41
Size - 191,45
Maximum - 10
Minimum - -10
TickFrequency - 2
Value - 0
TrackBar2
Location - 76,80
Size - 191,45
Maximum - 100
Minimum - 0
TickFrequency - 10
Value - 50
65. Right click anywhere on the form and click View Code, erase whatever code is present there and then paste this code-
66. Close the form and then go to Form1 and double click on the Find menu sub item under Find & Replace and add this code to it-
67. Double click on the Replace menu sub item under Find & Replace and add this code to it-
68. Double click on the Find & Replace menu sub item under Find & Replace and add this code to it-
69. Double click on the Selected Text menu sub item under Text Reader and add this code to it-
70. Double click on the Full Document menu sub item under Text Reader and add this code to it-
71. Double click on the Settings menu sub item under Text Reader and add this code to it-
72. Double click on the Stop Speaking menu sub item under Text Reader and add this code to it-
Here are the project files-
http://www.mediafire.com/?val27z04da3t55g
Here I present my first tutorial!!
In this tutorial I am going to teach you how to make an advanced text editor!!! :D
Hope you like it!!! :D cooll;
1. First open up VB.NET and create a new Windows Forms project with framework version 3.00.
2. After the project loads edit Form 1's these properties -
Size - 864, 659
StartPosition - CenterScreen
Text - Advanced Text Editor
3. Then drag a Menustrip, OpenFileDialog and SaveFileDialog onto the Form and then create menu items in the same order as that in this screen shot -
[img]http://farm6.static.flickr.com/5007/5303620235_e74def2012_z.jpg[/img]
4. Now add sub items under the file menu item in the same order as given below-
Open
Save
Save As
New
Exit
5. Now add sub items under the Font menu item in the same order as given below-
Font Type
Font Style (add sub items under this in the same order as given- Bold,Underline,Italic,Strikeout)
Font Color
Convert Case (add sub items under this in the same order as given- To UPPER,To lower)
6. Now add sub items under the Page menu item in the same order as given below-
Page Color
7. Now add sub items under the Text Alignment menu item in the same order as given below-
Left
Center
Right
8. Now add sub items under the Indent menu item in the same order as given below-
+1
-1
9. Now add sub items under the Bullets menu item in the same order as given below-
Add
Remove
10. Now add sub items under the Find & Replace menu item in the same order as given below-
Find
Replace
Find & Replace
11. Now add sub items under the Insert menu item in the same order as given below-
Image
12. Now add sub items under the Zoom menu item in the same order as given below-
In
Out
13. Now add sub items under the Undo & Redo menu item in the same order as given below-
Undo
Redo
14. Now add sub items under the Clipboard menu item in the same order as given below-
Copy
Cut
Paste
Select All Text
Erase All Text
15. Now add sub items under the View In menu item in the same order as given below-
Web Browser
16. Now add sub items under the Text Reader menu item in the same order as given below-
Selected Text
Full Document
Settings
Stop Speaking
17. Drag a Status strip on to the form and create Tool strip status labels in the same order as in the screen shot above.
18. Drag 5 labels from the toolbox on to the status strip and change these properties-
Visible = False
19. Change Label5's text property to 50 and Label4's text property to 0.
20. Drag a Rich text box from the toolbox on to the form and change these properties of it-
Dock - Fill
21. Now click on the VB.NET menu item called Project and then select Add Reference. Then go to the .NET tab and then search for System.Speech. Once you find it, select it and then click OK.
22. Now right click anywhere on the form and then click on view code and paste this code above Public Class Form1-
Code
Imports System.Speech.Synthesis
Imports System.IOCode
Dim cf As String
Private p_objSynth As New SpeechSynthesizer23. Double click on the Open menu item under the File menu item of the menustrip on the form and add this code to it-
Code
If RichTextBox1.Modified Then
Dim answer As Integer
answer = MessageBox.Show("The current document has not been saved, would you like to continue without saving?", "Unsaved Document", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If answer = Windows.Forms.DialogResult.No Then
Exit Sub
Else
Openthefile()
End If
Else
Openthefile()
End If
Private Sub Openthefile()
Try
OpenFileDialog1.Title = "RTE - Open File"
OpenFileDialog1.DefaultExt = "rtf"
OpenFileDialog1.Filter = "Text Files (*.txt)|*.txt|Rich Text Files (*.rtf)|*.rtf|HTML Files (*.htm,*.html)|*.htm,*.html|VB Files (*.vb)|*.vb|PHP Files (*.php)|*.php|All Files (*.*)|*.*"
OpenFileDialog1.FilterIndex = 1
OpenFileDialog1.ShowDialog()
Label1.Text = OpenFileDialog1.SafeFileName
Label2.Text = OpenFileDialog1.FileName
If OpenFileDialog1.FileName = "" Then Exit Sub
Dim strExt As String
strExt = System.IO.Path.GetExtension(OpenFileDialog1.FileName)
strExt = strExt.ToUpper()
Select Case strExt
Case ".RTF"
RichTextBox1.LoadFile(OpenFileDialog1.FileName, RichTextBoxStreamType.RichText)
Case Else
Dim txtReader As System.IO.StreamReader
txtReader = New System.IO.StreamReader(OpenFileDialog1.FileName)
RichTextBox1.Text = txtReader.ReadToEnd
txtReader.Close()
txtReader = Nothing
RichTextBox1.SelectionStart = 0
RichTextBox1.SelectionLength = 0
End Select
cf = OpenFileDialog1.FileName
RichTextBox1.Modified = False
Catch EX As Exception
MsgBox("Unidentified Error!!", MsgBoxStyle.Critical)
End Try
End Sub24. Similarly double click on the Save menu item and add this code to it-
Code
If cf = "" Then
SaveAsToolStripMenuItem.PerformClick()
Exit Sub
End If
Dim strExt As String
strExt = System.IO.Path.GetExtension(cf)
strExt = strExt.ToUpper()
Select Case strExt
Case ".RTF"
RichTextBox1.SaveFile(cf)
Case Else
Dim txtWriter As System.IO.StreamWriter
txtWriter = New System.IO.StreamWriter(cf)
txtWriter.Write(RichTextBox1.Text)
txtWriter.Close()
txtWriter = Nothing
RichTextBox1.SelectionStart = 0
RichTextBox1.SelectionLength = 0
RichTextBox1.Modified = False
End Select25. Now double click on the Save As menu item and add this code to it-
Code
SaveFileDialog1.Title = "RTE - Save File"
SaveFileDialog1.DefaultExt = "rtf"
SaveFileDialog1.Filter = "Text Files (*.txt)|*.txt|Rich Text Files (*.rtf)|*.rtf|HTML Files (*.htm,*.html)|*.htm,*.html|All Files (*.*)|*.*"
SaveFileDialog1.FilterIndex = 1
SaveFileDialog1.ShowDialog()
If SaveFileDialog1.FileName = "" Then Exit Sub
Dim strExt As String
strExt = System.IO.Path.GetExtension(SaveFileDialog1.FileName)
strExt = strExt.ToUpper()
Select Case strExt
Case ".RTF"
RichTextBox1.SaveFile(SaveFileDialog1.FileName, RichTextBoxStreamType.RichText)
Case ".TXT"
Dim confirm As Integer
confirm = MsgBox("All formatting will be lost if you save it in the .txt format. You should save the file in the .rtf format to save the file with the formatting. Would you like to continue saving the file in the .txt format?", vbYesNo + vbQuestion)
If confirm = vbYes Then
Dim txtWriter As System.IO.StreamWriter
txtWriter = New System.IO.StreamWriter(SaveFileDialog1.FileName)
txtWriter.Write(RichTextBox1.Text)
txtWriter.Close()
txtWriter = Nothing
RichTextBox1.SelectionStart = 0
RichTextBox1.SelectionLength = 0
Else
SaveFileDialog1.ShowDialog()
End If
Case Else
Dim txtWriter As System.IO.StreamWriter
txtWriter = New System.IO.StreamWriter(SaveFileDialog1.FileName)
txtWriter.Write(RichTextBox1.Text)
txtWriter.Close()
txtWriter = Nothing
RichTextBox1.SelectionStart = 0
RichTextBox1.SelectionLength = 0
End Select
cf = SaveFileDialog1.FileName
RichTextBox1.Modified = False26. Double Click on the New menu item and add this code to it-
Code
If RichTextBox1.Modified Then
Dim answer As Integer
answer = MessageBox.Show("The current document has not been saved, would you like to continue without saving?", "Unsaved Document", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If answer = Windows.Forms.DialogResult.Yes Then
RichTextBox1.Clear()
Else
Exit Sub
End If
Else
RichTextBox1.Clear()
End If
cf = ""27. Double click on the Exit menu sub item under File and add this code to it-
Code
If RichTextBox1.Modified = True Then
Dim response As MsgBoxResult
response = MsgBox("Do you want to close without saving?", MsgBoxStyle.Question + MsgBoxStyle.YesNo, "Confirm")
If response = MsgBoxResult.Yes Then
Me.Dispose()
ElseIf response = MsgBoxResult.No Then
SaveToolStripMenuItem.PerformClick()
End If
End If
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
If RichTextBox1.Modified = True Then
Dim response As MsgBoxResult
response = MsgBox("Do you want to close without saving?", MsgBoxStyle.Question + MsgBoxStyle.YesNo, "Confirm")
If response = MsgBoxResult.Yes Then
Me.Dispose()
ElseIf response = MsgBoxResult.No Then
e.Cancel = True
SaveToolStripMenuItem.PerformClick()
Exit Sub
End If
End If
End Sub28. Double click on Font Type menu item and add this code to it-
Code
Try
Dim fontstyle As New FontDialog
fontstyle.ShowDialog()
RichTextBox1.SelectionFont = fontstyle.Font
Catch ex As Exception
MsgBox(ex)
End Try29. Double Click on the Bold menu sub item under Font-->Font Styles and add this code to it-
Code
Dim currentf As System.Drawing.Font = RichTextBox1.SelectionFont
Dim nfs As System.Drawing.FontStyle
If RichTextBox1.SelectionFont.Bold = True Then
nfs = FontStyle.Regular
Else
nfs = FontStyle.Bold
End If
RichTextBox1.SelectionFont = New Font(currentf.FontFamily, currentf.Size, nfs)30. Double Click on the Underlinemenu sub item under Font-->Font Styles and add this code to it-
Code
Dim currentf As System.Drawing.Font = RichTextBox1.SelectionFont
Dim nfs As System.Drawing.FontStyle
If RichTextBox1.SelectionFont.Underline = True Then
nfs = FontStyle.Regular
Else
nfs = FontStyle.Underline
End If
RichTextBox1.SelectionFont = New Font(currentf.FontFamily, currentf.Size, nfs)31. Double Click on the Italic menu sub item under Font-->Font Styles and add this code to it-
Code
Dim currentf As System.Drawing.Font = RichTextBox1.SelectionFont
Dim nfs As System.Drawing.FontStyle
If RichTextBox1.SelectionFont.Italic = True Then
nfs = FontStyle.Regular
Else
nfs = FontStyle.Italic
End If
RichTextBox1.SelectionFont = New Font(currentf.FontFamily, currentf.Size, nfs)32. Double Click on the Strikeout menu sub item under Font-->Font Styles and add this code to it-
Code
Dim currentf As System.Drawing.Font = RichTextBox1.SelectionFont
Dim nfs As System.Drawing.FontStyle
If RichTextBox1.SelectionFont.Strikeout = True Then
nfs = FontStyle.Regular
Else
nfs = FontStyle.Strikeout
End If
RichTextBox1.SelectionFont = New Font(currentf.FontFamily, currentf.Size, nfs)33. Double Click on the Font Color menu sub item under Font and add this code to it-
Code
Dim fontc As New ColorDialog
fontc.ShowDialog()
RichTextBox1.SelectionColor = fontc.Color34. Double click on the Page Color menu sub item under Page and add this code to it-
Code
Dim pagec As New ColorDialog
pagec.ShowDialog()
RichTextBox1.BackColor = pagec.Color35. Double click on the Left menu sub item under Text Alignment and add this code to it-
Code
RichTextBox1.SelectionAlignment = HorizontalAlignment.Left36. Double click on the Center menu sub item under Text Alignment and add this code it-
Code
RichTextBox1.SelectionAlignment = HorizontalAlignment.Center37. Double click on the Right menu sub item under Text Alignment and add this code to it-
Code
RichTextBox1.SelectionAlignment = HorizontalAlignment.Right38. Double click on the +1 menu sub item under Indent and add this code to it-
Code
RichTextBox1.SelectionIndent += 139. Double click on the -1 menu sub item under Indent and add this code to it-
Code
Try
RichTextBox1.SelectionIndent -= 1
Catch ex As Exception
MsgBox("Minimum possible indent reached!!!", MsgBoxStyle.Critical, "Indent Error")
End Try40. Double click on the Add menu sub item under Bullets and add this code to it-
Code
RichTextBox1.BulletIndent = 10
RichTextBox1.SelectionBullet = True41. Double click on the Remove menu sub item under Bullets and add this code to it-
Code
RichTextBox1.SelectionBullet = False
RichTextBox1.SelectionIndent -= 142. Double click on the Image menu sub item under Image and add this code it-
Code
Try
Dim OpenFileDialog1 As New OpenFileDialog
OpenFileDialog1.Filter = "All Files |*.*"
OpenFileDialog1.Multiselect = True
Dim orgdata = Clipboard.GetDataObject
If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
For Each fname As String In OpenFileDialog1.FileNames
Dim img As Image = Image.FromFile(fname)
Clipboard.SetImage(img)
RichTextBox1.Paste()
Next
End If
Catch ex As Exception
MsgBox("Unknown Error" & vbCrLf + "Invalid Image", MsgBoxStyle.Critical)
End Try43. Double click on the In menu sub item under Zoom and add this code to it-
Code
RichTextBox1.ZoomFactor += 144. Double click on the Out menu sub item under Zoom and add this code to it-
Code
Try
RichTextBox1.ZoomFactor -= 1
Catch ex As Exception
MsgBox("Minimum possible zoom factor reached!!!", MsgBoxStyle.Critical, "Zoom Out Error")
End Try45. Double click on the Undo menu sub item under Undo & Redo and add this code to it-
Code
RichTextBox1.Undo()46. Double click on the Redo menu sub item under Undo & Redo and add this code it-
Code
RichTextBox1.Redo()47. Double click on the Copy sub menu item under Clipboard and add this code to it-
Code
RichTextBox1.Copy()48. Double click on the Cut sub menu item under Clipboard and add this code to it-
Code
RichTextBox1.Cut()49. Double click on the Paste menu sub item under Clipboard and add this code to it-
Code
RichTextBox1.Paste()50. Double click on the Select All Text menu sub item under Clipboard and add this code it-
Code
RichTextBox1.SelectAll()51. Double click on the Erase All Text menu sub item under Clipboard and add this code to it-
Code
RichTextBox1.Text = ""52. Double click on the Web Browser menu sub item under View In and add this code to it-
Code
Dim w As StreamWriter = New StreamWriter(Environment.CurrentDirectory & "\" & "npwb.html")
w.WriteLine(RichTextBox1.Text)
w.Close()
Process.Start("npwb.html")53. Now add a new form to your project by clicking the VB.NET menustrip--> Project-->Add Windows Form and then name it Form2 and change its these properties-
FormBorderStyle - FixedSingle
MaximizeBox - False
Size - 343,183
Text - Find & Replace
54. Add 2 labels, 2 Text boxes, 1 check box, 4 buttons on to the form and change its these properties-
Label1
Location - 3,9
Text - Find What
TextBox1
Location - 6,25
Size - 319,20
Label2
Location - 3,58
Text - Replace With
TextBox2
Location - 6,74
Size - 319,20
Button1
Location - 6,124
Size - 75,23
Text - Find
Button2
Location - 87, 124
Size - 75,23
Text - Find Next
Button3
Location - 168,124
Size - 75,23
Text - Replace
Button4
Location - 249,124
Size - 75,23
Text - Replace All
CheckBox1
Location - 6,101
Text - Match Case
55. Double click on the Find button and add this code to it-
Code
Dim sp As Integer
Dim st As CompareMethod
If CheckBox1.Checked = True Then
st = CompareMethod.Binary
Else
st = CompareMethod.Text
End If
sp = InStr(1, Form1.RichTextBox1.Text, TextBox1.Text, st)
If sp = 0 Then
MessageBox.Show("String: '" & TextBox1.Text.ToString() & "' not found", "No Matches", MessageBoxButtons.OK, MessageBoxIcon.Asterisk)
Exit Sub
End If
Form1.RichTextBox1.Select(sp - 1, TextBox1.Text.Length)
Form1.RichTextBox1.ScrollToCaret()
Form1.Focus()56. Double click on the Find Next button and paste this code-
Code
Dim sp As Integer = Form1.RichTextBox1.SelectionStart + 2
Dim st As CompareMethod
If CheckBox1.Checked = True Then
st = CompareMethod.Binary
Else
st = CompareMethod.Text
End If
sp = InStr(sp, Form1.RichTextBox1.Text, TextBox1.Text, st)
If sp = 0 Then
MessageBox.Show("String: '" & TextBox1.Text.ToString() & "' not found", "No Matches", MessageBoxButtons.OK, MessageBoxIcon.Asterisk)
Exit Sub
End If
Form1.RichTextBox1.Select(sp - 1, TextBox1.Text.Length)
Form1.RichTextBox1.ScrollToCaret()
Form1.Focus()57. Double click on the Replace button and add this code to it-
Code
If Form1.RichTextBox1.SelectedText.Length <> 0 Then
Form1.RichTextBox1.SelectedText = TextBox2.Text
End If
Dim sp As Integer = Form1.RichTextBox1.SelectionStart + 2
Dim st As CompareMethod
If CheckBox1.Checked = True Then
st = CompareMethod.Binary
Else
st = CompareMethod.Text
End If
sp = InStr(sp, Form1.RichTextBox1.Text, TextBox1.Text, st)
If sp = 0 Then
MessageBox.Show("String: '" & TextBox1.Text.ToString() & "' not found", "No Matches", MessageBoxButtons.OK, MessageBoxIcon.Asterisk)
Exit Sub
End If
Form1.RichTextBox1.Select(sp - 1, TextBox1.Text.Length)
Form1.RichTextBox1.ScrollToCaret()
Form1.Focus()58. Double click on the Replace All button and add this code to it-
Code
Dim cp As Integer = Form1.RichTextBox1.SelectionStart
Dim cs As Integer = Form1.RichTextBox1.SelectionLength
Form1.RichTextBox1.Rtf = Replace(Form1.RichTextBox1.Rtf, Trim(TextBox1.Text), Trim(TextBox2.Text))
Form1.RichTextBox1.SelectionStart = cp
Form1.RichTextBox1.SelectionLength = cs
Form1.Focus()59. Create one more new form by clicking on VB.NET menu item called Project-->Add Windows Form and name the form Form3 and change these properties of it-
FormBorderStyle - FixedSingle
MaximizeBox - False
Size - 283, 106
Text - Find
60. Drag 1 label, 1 Textbox, 1 check box and 2 buttons on to the form and change its these properties-
Label1
Location - 3,9
Text - Find What
TextBox1
Location - 6,26
Size - 259,20
CheckBox1
Location - 6,53
Text - Match Case
Button1
Location - 109,47
Size - 75,23
Text - Find
Button2
Location - 190,47
Size - 75,23
Text - Find Next
61. Double click on the Find button on the Form and add this code to it-
Code
Dim sp As Integer
Dim st As CompareMethod
If CheckBox1.Checked = True Then
st = CompareMethod.Binary
Else
st = CompareMethod.Text
End If
sp = InStr(1, Form1.RichTextBox1.Text, TextBox1.Text, st)
If sp = 0 Then
MessageBox.Show("String: '" & TextBox1.Text.ToString() & "' not found", "No Matches", MessageBoxButtons.OK, MessageBoxIcon.Asterisk)
Exit Sub
End If
Form1.RichTextBox1.Select(sp - 1, TextBox1.Text.Length)
Form1.RichTextBox1.ScrollToCaret()
Form1.Focus()62. Double click on the Find Next button on the Form and add this code to its-
Code
Dim sp As Integer = Form1.RichTextBox1.SelectionStart + 2
Dim st As CompareMethod
If CheckBox1.Checked = True Then
st = CompareMethod.Binary
Else
st = CompareMethod.Text
End If
sp = InStr(sp, Form1.RichTextBox1.Text, TextBox1.Text, st)
If sp = 0 Then
MessageBox.Show("String: '" & TextBox1.Text.ToString() & "' not found", "No Matches", MessageBoxButtons.OK, MessageBoxIcon.Asterisk)
Exit Sub
End If
Form1.RichTextBox1.Select(sp - 1, TextBox1.Text.Length)
Form1.RichTextBox1.ScrollToCaret()
Form1.Focus()63. Create a new Windows Form by clicking on the VB.NET menu item called Project-->Add Windows Form and then name it Form4.vb and then its these properties-
FormBorderStyle - FixedSingle
MaximizeBox - False
Size - 285,157
Text - Text Reader Settings
64. Drag 3 labels, 2 trackbars and 1 combo box from the toolbox on to the form and change its these properties-
Label1
Location - 3,17
Text - Select Voice :
Label2
Location - 12,50
Text - Speed :
Label3
Location - 12,91
Text - Volume
ComboBox1
Location - 76,14
Size - 191,21
Text - Microsoft Anna
TrackBar1
Location - 76,41
Size - 191,45
Maximum - 10
Minimum - -10
TickFrequency - 2
Value - 0
TrackBar2
Location - 76,80
Size - 191,45
Maximum - 100
Minimum - 0
TickFrequency - 10
Value - 50
65. Right click anywhere on the form and click View Code, erase whatever code is present there and then paste this code-
Code
Imports System.Speech.Synthesis
Imports System.Collections.ObjectModel
Public Class Form4
Private p_objSynth As New SpeechSynthesizer
Private Sub Form4_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TrackBar1.Value = Form1.Label4.Text
TrackBar2.Value = Form1.Label5.Text
ComboBox1.Text = Form1.Label3.Text
Dim objvoices As ReadOnlyCollection(Of InstalledVoice) = p_objSynth.GetInstalledVoices(Globalization.CultureInfo.CurrentCulture)
Dim objvoiceInformation As VoiceInfo = objvoices(0).VoiceInfo
For Each tmpvoice As InstalledVoice In objvoices
objvoiceInformation = tmpvoice.VoiceInfo
ComboBox1.Items.Add(objvoiceInformation.Name.ToString)
Next
End Sub
Private Sub TrackBar1_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TrackBar1.ValueChanged
p_objSynth.Rate = TrackBar1.Value
Form1.Label4.Text = TrackBar1.Value()
End Sub
Private Sub TrackBar2_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TrackBar2.ValueChanged
p_objSynth.Volume = TrackBar2.Value
Form1.Label5.Text = TrackBar2.Value()
End Sub
Private Sub ComboBox1_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.TextChanged
Form1.Label3.Text = ComboBox1.Text
End Sub
End Class66. Close the form and then go to Form1 and double click on the Find menu sub item under Find & Replace and add this code to it-
Code
Form3.Show()67. Double click on the Replace menu sub item under Find & Replace and add this code to it-
Code
Form2.Show()68. Double click on the Find & Replace menu sub item under Find & Replace and add this code to it-
Code
Form2.Show()69. Double click on the Selected Text menu sub item under Text Reader and add this code to it-
Code
p_objSynth.SelectVoice(Form4.ComboBox1.Text)
p_objSynth.SpeakAsync(RichTextBox1.SelectedText)
p_objSynth.Rate = Form4.TrackBar1.Value
p_objSynth.Volume = Form4.TrackBar2.Value70. Double click on the Full Document menu sub item under Text Reader and add this code to it-
Code
p_objSynth.SelectVoice(Form4.ComboBox1.Text)
p_objSynth.SpeakAsync(RichTextBox1.Text)
p_objSynth.Rate = Form4.TrackBar1.Value
p_objSynth.Volume = Form4.TrackBar2.Value71. Double click on the Settings menu sub item under Text Reader and add this code to it-
Code
Form4.Show()72. Double click on the Stop Speaking menu sub item under Text Reader and add this code to it-
Code
p_objSynth.SpeakAsyncCancelAll()Here are the project files-
http://www.mediafire.com/?val27z04da3t55g



