+ Reply to Thread
Results 1 to 5 of 5

Thread: Tutorial - OptionButtons + Command Buttons!

  1. #1
    travy92's Avatar
    travy92 is offline Learning Programmer
    Join Date
    Sep 2007
    Location
    Australia
    Posts
    76
    Rep Power
    17

    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:

    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!:

    Private Sub Command1_Click()
    Tells VB to do whatever code is specified under that line when the Command1 button is clicked.
    __________________________________________________ _______

    If Option1.Value = True Then
    Print "Hello"
    This code means that IF the Option1 button is ticked, print the word "Hello".
    __________________________________________________ _______

    ElseIf Option2.Value = True Then
    Print "Hey"
    Basically the same as the code above this one BUT this one is the Option2 Button.
    __________________________________________________ _______

    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:

    If Option1.Value = 1 Then
    Print "Hello"
    Replace the above code with the below code:

    List1.AddItem "Hello"
    ----------------------------------------------------------------

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

    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 Attached Files
    Last edited by Jordan; 09-13-2007 at 06:19 AM.
    C:\Users\Travis\Desktop\Image Converter\Knight1.bmp

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Location
    Advertising world
    Posts
    Many

     
  3. #2
    honokasu is offline Newbie
    Join Date
    Jan 2009
    Posts
    2
    Rep Power
    0

    Re: Tutorial - OptionButtons + Command Buttons!

    thank

  4. #3
    LCD
    LCD is offline Newbie
    Join Date
    Mar 2009
    Posts
    15
    Rep Power
    0
    cool..

    nicely done
    Last edited by WingedPanther; 03-14-2009 at 05:42 AM. Reason: Double post

  5. #4
    Xoo
    Xoo is offline Newbie
    Join Date
    Mar 2009
    Posts
    1
    Rep Power
    0

    Re: Tutorial - OptionButtons + Command Buttons!

    cool

  6. #5
    AlexT2145's Avatar
    AlexT2145 is offline Newbie
    Join Date
    Jul 2009
    Posts
    4
    Rep Power
    0

    Re: Tutorial - OptionButtons + Command Buttons!

    Good Job

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 2 users browsing this thread. (0 members and 2 guests)

Similar Threads

  1. VB6.0:Tutorial, Command Line
    By TcM in forum Visual Basic Tutorials
    Replies: 11
    Last Post: 07-26-2009, 11:09 AM
  2. Interface, command buttons, menus.
    By ld_pvl in forum Java Help
    Replies: 3
    Last Post: 10-26-2008, 05:07 AM
  3. Java:Tutorial - Adding Buttons to your Interface
    By John in forum Java Tutorials
    Replies: 0
    Last Post: 01-11-2007, 12:03 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts