INTRO
Ok, so basically we'll be making a program that prints off different text onto the form when a certain OptionButton is pressed.
-------------------------------------------------------------------
GUI (LAYOUT)
Here is my GUI:
-------------------------------------------------------------------
WHAT YOU NEED:
1 Command Button with:
Name: Command1
Caption: Print
3 Option Buttons with:
#1 Option Button:
Name: Option1
Caption: Hello
#2 Option Button:
Name: Option2
Caption: Hey
#3 Option Button:
Name: Option3
Caption: None (Seriously, put "None" as the caption look at the GUI to see it.)
-------------------------------------------------------------------
CODE:
Quote:
Private Sub Command1_Click()
If Option1.Value = True Then
Print "Hello"
ElseIf Option2.Value = True Then
Print "Hey"
End If
End Sub
|
A very simple code for a very simple program !
-----------------------------------------------------------------
CODE EXPLANATION!:
Quote:
|
Private Sub Command1_Click()
|
Tells VB to do whatever code is specified under that line when the Command1 button is clicked.
__________________________________________________ _______
Quote:
If Option1.Value = True Then
Print "Hello"
|
This code means that IF the Option1 button is ticked, print the word "Hello".
__________________________________________________ _______
Quote:
ElseIf Option2.Value = True Then
Print "Hey"
|
Basically the same as the code above this one BUT this one is the Option2 Button.
__________________________________________________ _______
Ends to coding for this button (Command1 button).
-----------------------------------------------------------------
EXTRA:
Well this tutorial is about printing things onto the Form. But you can change this by:
1) Add a ListBox into the Form with:
Name: List1
Caption: (None)
2) Add these codes into the coding section of VB:
A) For the part that says:
Quote:
If Option1.Value = 1 Then
Print "Hello"
|
Replace the above code with the below code:
----------------------------------------------------------------
B)
Quote:
ElseIf Option2.Value = True Then
Print "Hey"
|
Replace the above code with the following code:
And you're done!
----------------------------------------------------------------
Thanks to Tcm9669 & TheComputerMaster for the Screenshot Program.
Thanks to YOU for appreciating my previous tutorials and inspiring me to make new tutorials!
Made by me, Travy92.
SAMPLES xD: