0% found this document useful (0 votes)
53 views3 pages

Object Property Setting Form Checkbox Checkbox Checkbox Optionbutton Optionbutton Optionbutton Textbox Commandbutton Caption

The document describes how to create a form in Visual Basic with checkboxes and option buttons that control font styles and color of text in a textbox. It includes code to: 1) Enable or disable a frame based on the state of a checkbox. 2) Set font styles like bold, italic, and underline for text in a textbox based on the state of corresponding checkboxes. 3) Set the text color in a textbox to blue, red, or green based on the selected option button. 4) Close the form when an exit button is clicked.

Uploaded by

h0nney
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views3 pages

Object Property Setting Form Checkbox Checkbox Checkbox Optionbutton Optionbutton Optionbutton Textbox Commandbutton Caption

The document describes how to create a form in Visual Basic with checkboxes and option buttons that control font styles and color of text in a textbox. It includes code to: 1) Enable or disable a frame based on the state of a checkbox. 2) Set font styles like bold, italic, and underline for text in a textbox based on the state of corresponding checkboxes. 3) Set the text color in a textbox to blue, red, or green based on the selected option button. 4) Close the form when an exit button is clicked.

Uploaded by

h0nney
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Private Sub Check1_Click()

Frame1.Enabled = (Check1.Value = vbChecked)


End Sub
Note that Value is the default property for CheckBox controls, so you can omit it in code. I
suggest that you not do that, however, because it would reduce the readability of your code.
The following example illustrates the use of CheckBox control
* Open a new Project and save the Form as CheckBox.frm and save the Project as
CheckBox.vbp
* Design the Form as shown below
Object Property Setting
Caption CheckBox
Form
Name frmCheckBox
Caption Bold
CheckBox
Name chkBold
Caption Italic
CheckBox
Name chkItalic
Caption Underline
CheckBox
Name chkUnderline
Caption Red
OptionButton
Name optRed
Caption Blue
OptionButton
Name optBlue
Caption Green
OptionButton
Name optGreen
Name txtDisplay
TextBox
Text (empty)
Caption Exit
CommandButton
Name cmdExit
Following code is typed in the Click() events of the CheckBoxes
Private Sub chkBold_Click()
If chkBold.Value = 1 Then
txtDisplay.FontBold = True
Else
txtDisplay.FontBold = False
End If
End Sub
Private Sub chkItalic_Click()
If chkItalic.Value = 1 Then
txtDisplay.FontItalic = True
Else
txtDisplay.FontItalic = False
End If
End Sub
Private Sub chkUnderline_Click()
If chkUnderline.Value = 1 Then
txtDisplay.FontUnderline = True
Else
txtDisplay.FontUnderline = False
End If
End Sub
Following code is typed in the Click() events of the OptionButtons
Private Sub optBlue_Click()
txtDisplay.ForeColor = vbBlue
End Sub
Private Sub optRed_Click()
txtDisplay.ForeColor = vbRed
End Sub
Private Sub optGreen_Click()
txtDisplay.ForeColor = vbGreen
End Sub
To terminate the program following code is typed in the Click() event of the Exit button
Private Sub cmdExit_Click()
End
End Sub

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy