KNOWN VISUAL BASIC (Part 6)
1.1. Creating Project Manage Property
Example 5:
Create a new project with StandardEXE to try playing with the property and the event even further. Add Label components, Text, Frame, OptionButton, checkbox and Command. Set looks like Figure 2.7 below:
When using the display in the frame, the frame must be made in advance of new components in it. Set the properties of each component such as table 2.2. follows:
These settings will be generated display applications such as in Figure 2.8 below.
Figure 2.8. Display for exercise 2.2
Click on the command1, add code so that the program becomes:
Private Sub Command1_Click ()
Label2.Caption = Text1.Text
End Sub
Click on command2, add code so that the program becomes:
Private Sub Command2_Click ()
End
End Sub
Click on Option1, add code so that the program becomes:
Private Sub Option1_Click ()
Label2.ForeColor = vbRed
End Sub
Label2.ForeColor is color property to change the text on Label2, and red vbRed is already provided by Visual Basic, for the other colors like blue using vbBlue. Click on Option2, add code so that the program becomes:
Private Sub Option2_Click ()
Label2.ForeColor = vbBlue
End Sub
Click on check1, add code so that the program becomes:
Private Sub Check1_Click ()
Label2.FontItalic = Check1.Value
End Sub
Click on check2, add code so that the program becomes:
Private Sub Check2_Click ()
Label2.FontBold = Check2.Value
End Sub
Label2.FontItalic the property to set whether the text in italics Label2 made or not, if the value True then the text into italics. Label2.FontBold the property to set whether the text in bold Label2 made or not, if the value True then the text becomes bold. Save the project with the name projectLatihan22. And run the program, enter the name of Achmad Basuki, set the text to be red and tilted like a picture 2.9.2.8. Display for exercise 2.2
Private Sub Command1_Click ()
Label2.Caption = Text1.Text
End Sub
Click on command2, add code so that the program becomes:
Private Sub Command2_Click ()
End
End Sub
Click on Option1, add code so that the program becomes:
Private Sub Option1_Click ()
Label2.ForeColor = vbRed
End Sub
Label2.ForeColor is color property to change the text on Label2, and red vbRed is already provided by Visual Basic, for the other colors like blue using vbBlue. Click on Option2, add code so that the program becomes:
Private Sub Option2_Click ()
Label2.ForeColor = vbBlue
End Sub
Click on check1, add code so that the program becomes:
Private Sub Check1_Click ()
Label2.FontItalic = Check1.Value
End Sub
Click on check2, add code so that the program becomes:
Private Sub Check2_Click ()
Label2.FontBold = Check2.Value
End Sub
Label2.FontItalic the property to set whether the text in italics Label2 made or not, if the value True then the text into italics. Label2.FontBold the property to set whether the text in bold Label2 made or not, if the value True then the text becomes bold. Save the project with the name projectLatihan22. And run the program, enter the name of Achmad Basuki, set the text to be red and tilted like a picture 2.9.2.8. Display for exercise 2.2