![]() |
![]() |
![]() |
|||||
![]() |
![]() |
![]() |
![]() |
![]() |
|||
| Welcome
to Tech Support Forum home to more then 136,000 problems solved. Issues
have included: Spyware, Malware, Virus Issues, Windows, Microsoft,
Linux, Networking, Security, Hardware, and Gaming Getting your
problem solved is as easy as: 1. Registering for a free account 2. Asking your question 3. Receiving an answer Registered members: * See fewer ads. * And much more..
|
| Want to know how to post a question? click here | Having problems with spyware and pop-ups? First Steps |
|
|||||||
| New Article Submissions Where new Articles are submitted and are pending for review |
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 (permalink) |
|
Mentor, Articles Team
|
Visual Basic Tutorial
Visual Basic Introductory Tutorial In this article we shall cover some of the basics of Visual Basic programming. Despite what the name of the programming suggests, Visual Basic can be used for very complex programs. ] BASIC stands for Beginner's All-purpose Symbolic Instruction Code, and the visual element is due to the fact that the programming relies on a graphic layout, as the Tutorial shall demonstrate later. The first bit of coding we shall look at is setting up a messagebox to display a message. Hello world msgbox Code:
Msgbox Prompt, [buttons as VbMsgBoxStyle = vbOKOnly], [ Title], [helpfile], [context], As VbMsgBoxResult
![]() Move the cursor back to the main Form view area. A Crosshair cursor should now replace the normal arrow cursor. Click and drag to place the command button. ![]() This should look something like the image on the left, although the placing and size is entirely up to you. ![]() To change the text displayed with Command Button, we need to go into the properties area. This is by default on the right hand side of the screen, and usually in the middle of all the other sections, although it can be detached. If you can’t see this, you need to do the following to make it appear. ![]() Or press the F4 key on the keyboard. To change the text on the button, we are concerned with the property called “caption” On the right hand side of the properties bar is the text currently in the box. We simply select this, and start typing what we want in there. For this exercise, this can be anything you want. To code for the Msgbox, go back into the Form Mode by pressing SHIFT + F7 Double click on the Command button again, and you will be presented with your first page of code. By double clicking on that button, the compiler adds the start and end bits of code that allow that button to do anything. Code:
Private Sub Command1_Click() Msgbox “Hello World”, vbOkOnly, “Hello World” End Sub ![]() You have written your first bit of code. In the next section you will look at conditional coding, which is crucial part of many programs. Conditional Statements: Unless you are programming a completely static program, where only one set of outcomes can arise, you will need to use conditional statements of some kind. The most basic type is the IF statement, and this is how it works and how we shall use it. The logic of an If statement is as follows: Code:
If Statement is (whatever we choose to test, usually true or false) Then do the following Code Else ( the above statement resolves as false) Do this code End the if statement Project: The idea of this project is to display a Msgbox, to capture the result of this MsgBox and display a relevant response in the program. The first job is to create variables, pieces of data stored by the program that allow us to do something dynamically and store responses to certain events in the program. View | Code Just above the area containing the code there are two dropdown menus. On the left hand one, select “General” The dropdown menu on the right will automatically change to “declarations” There is now a space above the Msgbox code we did last. Enter the following code: Code:
Dim response As Integer Still in Code view, go back to this sub we wrote earlier Code:
Private Sub Command1_Click() Msgbox “Hello World”, vbOkOnly, “Hello World” End Sub Code:
response = MsgBox("Hello World", vbYesNo, "Hello World")
Code:
Msgbox “Hello World”, vbOkOnly, “Hello World” Returning to Code:
If (response = "6") Then
MsgBox ("Yes")
Else
MsgBox ("No")
End If
[end of article]
__________________
"Freedom of thought is best promoted by the gradual illumination of men's minds, which follows from the advance of science" - Darwin Join the TSF folding team - Team 85015 Last edited by TheAtheist; 01-02-2009 at 04:13 PM. |
|
|
| Important Information |
|
Join the #1 Tech Support Forum Today - It's Totally Free!
TechSupportForum.com is a leading support website for your computer needs. We offer free, friendly and personalized computer support. Why pay to have your computer fixed when you can do it for free. Join TechSupportforum.com Today - Click Here |
|
|
#2 (permalink) |
|
Manager Home Support, Assistant Manager Articles Team
|
Re: Visual Basic Tutorial - WIP - images to be added soon
Nice one Joe. Which version of VB is it?
Can I help out with imaging?
__________________
. Lest we forget... "They shall grow not old, as we that are left grow old; Age shall not weary them, nor the years condemn. At the going down of the sun and in the morning We will remember them." |
|
|
|
|
#3 (permalink) |
|
Mentor, Articles Team
|
Re: Visual Basic Tutorial - WIP - images to be added soon
Doh, how did i forget that detail! - Its for VB6. All the images are being sorted right now, using my newly aquired Photoshop Pro!
__________________
"Freedom of thought is best promoted by the gradual illumination of men's minds, which follows from the advance of science" - Darwin Join the TSF folding team - Team 85015 |
|
|
|
|
#4 (permalink) |
|
Mentor, Articles Team
|
Re: Visual Basic Tutorial - WIP - images to be added soon
Any more comments on this one from any member? This ones been sitting around a while and i'd like if possible to get it published soonish if no one objects to that.
__________________
"Freedom of thought is best promoted by the gradual illumination of men's minds, which follows from the advance of science" - Darwin Join the TSF folding team - Team 85015 |
|
|
|
|
#5 (permalink) |
|
Mentor, Articles Team
|
Re: Visual Basic Tutorial - WIP - images to be added soon
Despite what i posted above, i'm going to rewrite this whole thing as there is a much more upto date version called Microsoft Visual basic 2008 - it's free as well!!!
__________________
"Freedom of thought is best promoted by the gradual illumination of men's minds, which follows from the advance of science" - Darwin Join the TSF folding team - Team 85015 |
|
|
|
|
#7 (permalink) |
|
Manager Home Support, Assistant Manager Articles Team
|
Re: Visual Basic Tutorial - WIP - images to be added soon
I'd be keen to see one on VB 2008....Better get the pencil sharpened!
__________________
. Lest we forget... "They shall grow not old, as we that are left grow old; Age shall not weary them, nor the years condemn. At the going down of the sun and in the morning We will remember them." |
|
|
|
|
#8 (permalink) |
|
Mentor, Articles Team
|
Re: Visual Basic Tutorial - WIP - images to be added soon
If you wouldn't mind John
![]() ![]() I'm going to run it this evening, see whats different in how i do what i did in vb6 and edit it that way!
__________________
"Freedom of thought is best promoted by the gradual illumination of men's minds, which follows from the advance of science" - Darwin Join the TSF folding team - Team 85015 |
|
|
![]() |
| Thread Tools | |
|
|