Write a VB.NET program to do the following operations on RichTextBox values i) Font Style ii) Font Color iii) Save iv) Open
Form:-
Program:-
Imports System.IO
Public Class slip20
Dim path As String
Private Sub FontStyleToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles FontStyleToolStripMenuItem.Click
FontDialog1.ShowDialog()
RichTextBox1.Font = FontDialog1.Font
End Sub
Private Sub FontColorToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles FontColorToolStripMenuItem.Click
ColorDialog1.ShowDialog()
RichTextBox1.ForeColor = ColorDialog1.Color
End Sub
Private Sub SaveToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles SaveToolStripMenuItem.Click
If DialogResult.OK = SaveFileDialog1.ShowDialog() Then ' To check file name is valid or not
path = SaveFileDialog1.FileName
RichTextBox1.SaveFile(path, RichTextBoxStreamType.PlainText)
MsgBox("File save successfully.........")
End If
End Sub
Private Sub OpenToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles OpenToolStripMenuItem.Click
If DialogResult.OK = OpenFileDialog1.ShowDialog() Then ' To check file name is valid or not
path = OpenFileDialog1.FileName
RichTextBox1.Text = (File.ReadAllText(path)).ToString
MsgBox("File Open successfully.........")
End If
End Sub
End Class
Output:-
Design:-
1) Take RichTextBox, MenuStrip, FontDialog, ColorDialog, OpenFileDialog, SaveFileDialog on design form.
2) Set Menu on MenuStrip.
Theory:-
Imports System.IO - This class contains a File method which is used to read content from a file.
FontDialog1.ShowDialog() - It is use to Display fontDialog. Which helps to select particular font from dialogbox.
FontDialog1.Font - It returns selected Font.
ColorDialog1.ShowDialog() - It is used to Display color Palette. Which helps to select a particular color from Palette.
ColorDialog1.Color - It returns selected color.
SaveFileDialog1.FileName - It returns filename with path.
RichTextBox1.SaveFile(path, RichTextBoxStreamType.PlainText) - This method save the file at given path and write a text into a file from RichTextBox.
(File.ReadAllText(path)).ToString - This File method is used to read text from a file in a byte. It needs to convert into the string.
-
Next Write HTML and CSS code to design a web page. Divide the browser screen into two frames. The first frame will display the heading. Divide the second frame into two columns. The frame on the right contains a image of “Home and Kitchen Appliances”. The frame on the left contains a menu consisting of hyperlinks. Clicking on any one of these hyperlinks will display related information in a new page as shown below. Use External style sheet with appropriate attributes to display information of each frame.
-
Previous Develop the menu based Vb.net application to implement a text editor with cut, copy, paste, save, close operations.
0 Comments