Lost Password?


  #1 (permalink)  
Old 09-13-2007, 05:27 AM
travy92's Avatar   
travy92 travy92 is offline
Learning Programmer
 
Join Date: Sep 2007
Location: Australia
Age: 15
Posts: 72
Rep Power: 5
travy92 is on a distinguished road
Send a message via MSN to travy92
Post Tutorial - OptionButtons + Command Buttons!

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.
__________________________________________________ _______

Quote:
End If
End Sub
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:

Quote:
List1.AddItem "Hello"
----------------------------------------------------------------

B)
Quote:
ElseIf Option2.Value = True Then
Print "Hey"
Replace the above code with the following code:

Quote:
List1.AddItem "Hey"
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:
Attached Files To view attachments in this forum your post count must be 1 or greater. You currently have 0 posts.
__________________
C:\Users\Travis\Desktop\Image Converter\Knight1.bmp

Last edited by Jordan; 09-13-2007 at 09:19 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Tutorial: C# Hello World Jordan CSharp Tutorials 15 10-16-2008 11:44 PM
John's Java Tutorial Index John Java Tutorials 0 01-11-2007 04:05 PM
A time showing tutorial ahsan16 VB Tutorials 1 01-10-2007 05:50 AM
JSP Tutorial encoder JavaScript and CSS 0 05-26-2006 06:31 AM


All times are GMT -5. The time now is 10:55 PM.

Contest Stats

WingedPanther ........ 2753.6
Xav ........ 2704
Brandon W ........ 1702.32
John ........ 1207.73
marwex89 ........ 1175.24
morefood2001 ........ 966.05
dcs ........ 655.75
Steve.L ........ 475.59
orjan ........ 418.58
Aereshaa ........ 383.54

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 100%


Complete - Celebrate!

Ads