|
In this article I am going to show you how you can use check box and option button in Microsoft Visual Basic 6. First of all create a new form and add one text box, two frames, three check boxes and two option buttons as shown in the image.
Now, write the code in the code window of the form on different events as shown below:
Now, write the code in the code window of the form on different events as shown below:
Private Sub chkbold_Click()
If chkbold.Value = 1 Then
Text1.Font.Bold = True
ElseIf chkbold.Value = 0 Then
Text1.Font.Bold = False
End If
End Sub
Private Sub chkitalic_Click()
If chkitalic.Value = 1 Then
Text1.Font.Italic = True
ElseIf chkitalic.Value = 0 Then
Text1.Font.Italic = False
End If
End Sub
Private Sub chkunderline_Click()
If chkunderline.Value = 1 Then
Text1.Font.Underline = True
ElseIf chkunderline.Value = 0 Then
Text1.Font.Underline = False
End If
End Sub
Private Sub Form_Load()
Text1.Text = "How to use Check box and Option Buttons in VB 6"
End Sub
Private Sub optblue_Click()
If optblue.Value = True Then
Text1.BackColor = vbBlue
End If
End Sub
Private Sub optgreen_Click()
If optgreen.Value = True Then
Text1.BackColor = vbGreen
End If
End Sub
0 comments:
Post a Comment