3.
Program to change the style of text in editor window according to
styles selected from checkboxes
Design View:
Source Code:
'Program to change the style of text in editor window according to styles selected from
checkboxes
Private Sub chkbold_Click()
If chkbold.Value = 1 Then
txteditor.FontBold = True
Else
txteditor.FontBold = False
End If
End Sub
Private Sub chkitalic_Click()
If chkitalic.Value = vbChecked Then
txteditor.FontItalic = True
ElseIf chkitalic.Value = vbUnchecked Then
txteditor.FontItalic = False
End If
End Sub
Private Sub Chkbolditalic_Click()
If Chkbolditalic.Value = vbChecked Then
txteditor.FontBold = True
txteditor.FontItalic = True
ElseIf Chkbolditalic.Value = vbUnchecked Then
txteditor.FontBold = False
txteditor.FontItalic = False
End If
End Sub
Private Sub Chkunder_Click()
txteditor.FontUnderline = Not txteditor.FontUnderline
End Sub
Private Sub Chkstrike_Click()
txteditor.FontStrikethru = Not txteditor.FontStrikethru
End Sub
Private Sub Chksize_Click()
Dim X As Integer
X = InputBox("enter the size", "size", 10, 1000, 2000)
txteditor.FontSize = X
End Sub
Private Sub Chkfname_Click()
Dim X As String
X = InputBox("Enter the font name", "Name", "Arial", 1000, 2000)
txteditor.FontName = X
End Sub
Private Sub Cmdend_Click()
Unload Me
End Sub
Output:
Viva Questions:
1. For what purpose checkbox is used?
Ans: It is used to select multiple options.
2. What is the role of inputbox?
Ans: It is used to accept value from user.
3. What is the use of value property?
Ans: Value property gives the value of checkbox(selected or not). 1=selected and 0=not
selected.
4. What is the use of vbchecked and vbunchecked?
Ans: It checks whether checkbox is selected or not. Vbchecked=selected and
vbunchecked=not selected.
5. What is the use of fontbold property?
Ans: It gives the bold effect to text.
6. What is the use of fontitalic property?
Ans: It gives the italic effect to text.
7. What is the use of fontunderline property?
Ans: It underlines the text .
8. What is the use of fontstrikethrough property?
Ans: It gives the strikethrough effect to text.