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:
A very simple code for a very simple program !Private Sub Command1_Click()
If Option1.Value = True Then
Print "Hello"
ElseIf Option2.Value = True Then
Print "Hey"
End If
End Sub
-----------------------------------------------------------------
CODE EXPLANATION!:
Tells VB to do whatever code is specified under that line when the Command1 button is clicked.Private Sub Command1_Click()
__________________________________________________ _______
This code means that IF the Option1 button is ticked, print the word "Hello".If Option1.Value = True Then
Print "Hello"
__________________________________________________ _______
Basically the same as the code above this one BUT this one is the Option2 Button.ElseIf Option2.Value = True Then
Print "Hey"
__________________________________________________ _______
Ends to coding for this button (Command1 button).End If
End Sub
-----------------------------------------------------------------
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:
Replace the above code with the below code:If Option1.Value = 1 Then
Print "Hello"
----------------------------------------------------------------List1.AddItem "Hello"
B)Replace the above code with the following code:ElseIf Option2.Value = True Then
Print "Hey"
And you're done!List1.AddItem "Hey"
----------------------------------------------------------------
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:
Last edited by Jordan; 09-13-2007 at 06:19 AM.
thank
cool..
nicely done
Last edited by WingedPanther; 03-14-2009 at 05:42 AM. Reason: Double post
cool
Good Job
There are currently 2 users browsing this thread. (0 members and 2 guests)
Bookmarks