A step by step tutorial teaching you how to create your own chat client and chat server easily in C#, for local networks or the Internet.
A C# tutorial showing you how to make use of WMI to extract information on disk drives, such as model, capacity, sectors and serial number.
This tutorial will teach you how to calculate the shipping cost based on the weight, height, length and depth of the box, the distance and the UPS service type.
Creating a Rich Text Editor using JavaScript is easier to do than you might think, thanks to the support of modern browsers; this tutorial will walk you through it.
Getting Started With Visual Basic 6.0Comprehensive tutorial aimed at introducing you to the basics of programming in Visual Basic 6.0. |
On Tuesday, March 16th 2004 at 07:21 AM By bs0d bs0d (View Profile) ![]() ![]() ![]() ![]() (Rated 4.1 with 71 votes) |
||||||||||||||||||||||||||||||||||
|
Contextual Ads
More Visual Basic Resources
Advertisement
Getting Started This tutorial does not completely cover all This tutorial was written assuming that you Also, it would not help much reading this Procedural vs. Non-Procedural Languages Procedural Languages - Programming languages that Examples of Procedural Languages: FORTRAN Non-Procedural Languages - Object-Oriented programming Examples of Procedural Languages: Visual Basic Labels, Text Boxes and Label - A control that is used to display text Examples of labels:
• lblName <br>
Text Box - Control that is used to enter information Examples of Text Boxes:
• txtSponge <br>
Command Buttons - Control used to activate a procedure. Types of Errors Syntax Errors - Compiler errors that occur Special Functions and VAL() - A function that will convert a string to
<var> = FORMAT(<var>,"<type
Examples:
lblTotal = Format(lblTotal,"Currency")
lblArea = Format(lblTotal,"Fixed")
' Formats number
LblPctTotal = Format(lblPctTotal,"Percent")
'Formats
lblSum = FormatCurrency(NumToFormat)<br>
lblTotal = FormatNumber(NumToFormat,NumOfDecimalPlaces)<br>
lblTotalPct = FormatPercent(NumToFormatAsPercent)<br>
lblCurrentDate = FormatDateTime(StartingDate, vbShortDate)<br>
Variables and Constants Option Explicit - A statement that will force you DECLARING A VARIABLE: When you declare a variable, VB reserves space in the RULES (for variable names): Variables must begin with a letter. The DIM statement is used to declare all variables in Syntax: Examples:
DIM inNum1 as Integer<br>
DECLARING A CONSTANT Constants are always declared using the keyword CONST. Syntax: Examples:
DIM sngPI as Single = 3.14<br>
NAMED CONSTANTS - These are vbRed SCOPES OF VARIABLES Scope - Is a term used to refer to the visibility Lifetime - The period of time that variables exist. 3 LEVELS OF SCOPE: Global Variable - Variable accessible anywhere PROPERTIES Default Property - Automatically selects a cmd Cancel Property - The button that is selected when TabStop Property - Represents all controls on a Some controls can receive focus, others cant. 0 - Left Justify MultiLine - Allows a string to be spread out among
lbl
Total.Visible = True 'label will
FillStyle - Primarily used 0 - Solid EXAMPLES :
<font size="3">• Square.FillStyle = 0 <br>
Option Buttons, Check Option Buttons - Group of controls where only one OPTION BUTTONS: The VALUE property of the option button is set TRUE if When assigning an option button, a variable name always If you want an event to occur when you click on an opt CHECK BOXES: More than one check box can be selected at a time. The VALUE property of the option button is set to CHECKED A second option is to set the VALUE property on check 0 - UnChecked Set the CAPTION property to the text you would like to When assigning a variable name, always start out with If you want an event to occur when you click on a chk IMAGES: Click on the images PICTURE property and locate the folder Select the pic you want and it will be placed on the form. Set images STRECH property to TRUE. This will size the All controls that are images should begin with img prefix. SHAPES: The types of shapes and codes are shown below... 0 - Rectangle LINES Use the crosshair pointer to drag a line across the screen. All line controls should begin with the lin prefix. Determining Focus Focus - Refers to the currently selected control Examples of setFocus:
txtNum1.setFocus '
will place cursor in the text
<font size="3">
'will hilight this command button.
<font size="3">
'will put dotted lines around this opt button. Working With Strings Concatenation - Refers to combining two or more Examples of Concatenation: StrFirstName + " " + strMiddleInitial + ". Formats CENTERING A FORM IN THE MIDDLE OF THE SCREEN: (This code would go in the FORM LOAD [ by double clicking
<Name of Form> - This If you named your form SQUARE, you would code the statement
SQUARE.Top = (Screen.Height - SQUARE.Height)/2<br>
Input Boxes Input Box - A function that will display a message The input box will have a txt box with the prompt above Input Boxes are often used when one wants to retrieve VariableName = InputBox("Prompt","Title") Examples:
StrName = InputBox("Enter your name",
Input Boxes can appear in the following places: Form_Load Form Load Form_Load - Code executed as the project is loading. Things that are done in the FORM_LOAD section of a VB Code to center the form in the middle of the screen To get the FORM_LOAD event to enter code, again; double Private Sub Form_Load() <Place Code Here>
Private Sub Form_Load()<br>
Message Box - A special type of VB statement/function The following can be displayed to the user with a Message Message MESSAGE BOX STATEMENT The message box statement is designed to be on a line
<font size="3">MsgBox< "Prompt">,<Buttons/Icons>,<"Caption"><br>
MESSAGE BOX FUNCTION: The message box function will appear on the right hand VarName = MsgBox(<"Prompt">,<Buttons/Icons>,<"Caption">)
IntRes = MsgBox("Are my fingers tired?",
Sample code using Message Boxes:
Private Sub cmdCheck_Click()<br>
List Box - A type of control used to hold a list Items can be added to a list box in two ways. Using the LIST property for the list control If your values are strings, they must be enclosed in double Example of - ADDING ITEMS TO THE LIST:
lstSchools.AddItem "Harvard"<br>
ListIndex PROPERTY :
<control>.ListIndex = 3 'This will highlight the
lstSchools.ListIndex = 3 'This will highlight the
Sorted PROPERTY: This will sort the items in your list alphabetically if Clear METHOD: This will empty out the contents of a list box...
<control>.Clear</font></p>
This will remove one item from the list. When using RemoveItem,
<control>.RemoveItem <index></font></p>
LstCount - The listCount property is used to hold Sub Procedures, Fonts, Procedure - A unit of code that performs a specific PURPOSES OF PROCEDURES: Breaks large sections of code into smaller units CREATING A NEW SUB PROCEDURE (in VB 6.0 Display the code window for the form Example of a Sub Procedure:
Private Sub AddNumbers()<br>
Private Sub cmdCalculate_Click()<br>
Example of a Function Procedure:
Private Function AddNumbers()<br>
Example of a Function Procedure Call:
Private Sub cmdCalculate_Click()<br>
The WITH keyword allows you to cut down on coding when Syntax of WITH statement: With <control> Assigning controls without the WITH KEYWORD:
l
<font size="2">blEmployee.Font.Name
With lblEmployee.Font<br>
Allows your project to use the dialog boxes that are provided FEATURES OF THE DIALOG CONTROL: You only need common dialog control on your form RETRIEVING THE COMMON DIALOG CONTROL: click on Project CHANGING FONTS: Example SYNTAX of SETTING FONTS: With dlgCommon (assuming that you named it that)
With txtName.Font<br>
Example SYNTAX of CHANGING COLOR:
<font color="#000000">dlgCommon.ShowColor 'Brings
RANDOM NUMBERS Rnd - Generates a random number between 0 and 1. Generating Numbers between 1 and 10:
Num = Int((10 - 1 + 1)* rnd + 1)
Generating Numbers between 1 and 100:
Num = Int((100 - 10 + 1)* rnd + 1)
Converts a floating point value to an integer by truncating Menus, Combo Boxes and Menu - A drop-down list of items displayed below In Windows and VB a menu consists of a menu bar with menu Menu commands are actually controls and have events and PARTS OF THE MENU: Caption - Holds the words you want to appear on COMBO BOXES Combo Box - A type of control used to hold a list DIFFERENCES BETWEEN A LIST BOX AND A COMBO BOX: With a list box, there is no pull down menu, user Using the List property ADDING ITEMS TO THE LIST USING THE LIST PROPERTY: 1.) Scroll through the properties window to the LIST property 1.) Double click on the form to open FORM_LOAD <object_name>.AddItem "<Value>" ADDING ITEMS INTO THE ItemData ARRAY: <object_name>.AddItem "<Value>" ADDING ITEMS TO THE LIST: Puttings items into the list of a Combo Box...
cboSchool.AddItem "Harvard"<br>
Harvard will have the index of 0, Yale of 1 and so on Entering Items into the ItemData array of a Combo Box...
cboOffice.AddItem "Paper"<br>
The Text property refers to the actual item that is currently <label> = <control>.Text
lblFood = cboFood.Text
ListIndex works as the same as List Boxes. Same as NewIndex, When naming Combo Boxes, use the prefix, "cbo". QB COLOR QBCOLOR - is a built-in function in VB that will
Example:
ShpRectangle.FillColor = QBColor(1) ‘Will be
Array - A group of data items that are referred Text Boxes Control Arrays are most commonly used with text boxes CREATING A CONTROL ARRAY: drop a control o the form and assign it a name Example Control Array using a Select Case: This example is if you had 6 option buttons with names
Private Sub optColors_Click(Index As Integer)<br>
SUM AND AVERAGE OF TEST SCORES USING CONTROL ARRAYS: Here is another example of a control array. This will
'Calculating Sum and Average<br>
'Clearing text boxes and totals<br>
Scroll Bar - A control that allows you to see hidden In VB a scroll bar is used to represent a range of values. Scroll Box - The little square, which appears inside PROPERTIES OF THE SCROLL BAR: Min - The smallest value the scroll bar can take TYPES OF SCROLL BARS: Vertical Scroll Bar - Begins with the prefix "vsb" EVENTS OF THE SCROLL BAR: Change Event - Occurs when the user clicks on the As soon as the user releases the mouse botton, the scroll SAMPLE PROGRAM USING HORIZONTAL SCROLL BAR:
Private Sub cmdExit_Click()<br>
Private Sub Form_Load()<br>
Private Sub hsbScroll_Change()<br>
Private Sub hsbScroll_Scroll()<br>
Private Sub cmdExit_Click()<br>
<font color="#000000">Private Sub Form_Load()<br>
Private Sub vsbScroll_Change()<br>
Private Sub vsbScroll_Scroll()<br>
The RGB function specifies the quantities of red, green Chosen_Color = RGB(RedValue, GreenValue,BlueValue) Examples:
RGB(0,0,0) 'would be <b>BLACK</b><br>
A VB project can consist of several forms. Each form has StartUp Form - The first form a project displays Load <form_name> Unload - Unloads the form from the computers memory. Unload <form_name> Show - Display the loaded form on the screen. <form_name>.Show Hide - Makes the form disappear. The form will <form_name>.Hide ME KEYWORD: You can refer to the current form by using the special Examples:
Unload Me 'Unloads the current form that is executing
|
|||||||||||||||||||||||||||||||||||
Digg It!
Del.icio.us
Reddit
StumbleIt
Newsvine
Furl
BlinkList
|
|||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||
Current CommentsIs there a limit of characters or something? It dont look like the entire tutorial got posted! -i'll try to re-paste the html...
No, there is no limit. Although, try to post it into several parts, this should also make the loading process shorter.
Thank you for your time.
As you can see, your tutorial was now submitted successfully.
Thanks very much this has give a clear point of view. This tutorial has been laid out clearly , short and to the point just what i need.
please include in the tutorial how to develop a networking application. and also how to create a setup program.
Very good Tutorial, Thanks.
I was wanting some assistance in writing a program where I have a form with a control array of four text boxes, txtInput, a command button, cmdAverage, and a label, lblAverage. I need to write a code such that when cmdAverage is clicked, lblAverage displays the average of the numbers in the four text boxes. I also need to use a loop in performing this calculation.
Would you be able to assist me.
Thanks
Renee'
your tutorial is very good but ps add some examples of simple program
Hey.. You should add Checklistbox example in there :)
how to connecting the databeses explain with an example program.
A very usefull document
VERY GOOD WORK..
MRK
Good work, Thanks a lot for this..........
ok
Thank you very much your work helped me a lot indeed. Keep it up!
good work.but add more examples
Good.Add more examples and explanations
thanks! very useful pls. give more examples...
u dont provide information about catabase connectvity
yah, i think its better to include more information pertaining to VB's database manipulation, connectivity and many more.
in fairness, it a great tutorial...basic-wise!
in fairness, it a great tutorial...basic-wise!
I think its a great guide as the title reads, "Getting Started..." Getting started would not include database connectivity and others of the like. Nice article, alot of information presented well.
There will always be haters for people who try to put together aticles like this- it IS a good read and is on this site for a reason.
/end my 2 cents
Good work , add source code with pictures.
Good and concise!
Simple, nice and consice ... thanks for sharing
using visaul basic program to find the currency conversion
would you gave me a sample program ..just send to my e-mail add...
pretty good!
It's Excellent.Thanks for sharing.Keep on sharing even your sample programs to us.
Excellent. Helpfull information.
I am currntly working on a macro to fill a cell in an excel workbook with a certain color if it\'s of a certain value. HELP!!!!
eg.
Cells(i, 4).Value = Gate1OPS505Status \'Col 4
If Gate1OPS505Status = \"1\" Then
Cells(i, 4).Value = \"O\"
Cells(i, 4).Font.ColorIndex = 3
As you can see I got the Font part going. How would I \"FillColor\" the cell?
it 's really very good.thanx.
please, please please...
send me some codes in comparing variables in date/time format
Make available tutorial in PDF format.
Visual Basic code samples can be found here:
http://www.allsyntax.com/code/Visual%20Basic/10/index.php
i need help with making circles and squares in an image box
for a paint project. i was wondering if you knew how to put those in a button also.
PLease i need a self explained tutorial on arrays in VB 6.0
give sample source code visual basic programming language for mathematic and equation it. and than give me a guide book.
that for my finalist project.
help me, send it soon. please
musa, love u
I got a project to make. But i need to know 2 things.
1.I need to use the Enter key to go from text1 to text2,3 and so on. Can anyone tell me wich command I got to use?
2.And each time I finish writing in one text what I wrote has to be shown in a Label that was created.Then when I finish with the text boxes all the written info on them have to be shown in a picture box. Can i also get commands fo this? I would appreciate it, my life is on the line in this one.
THX a lot, without this i would be cicling round and round.
Hey thanx for the tutorial
I was wondering if you could provide an example as how Set up a program that includes Check boxes and Option Boxes. The reason being is i have to make a program which wen one option box of two option box is selected the value of 4 other check boxes change so that wen those cehck boxes are added they display amount in a label
would appreciate it thanx
very concise. gives a good introduction. thanx
It is an informative tutorials.it has learnt me a lot of konowledge of visual basic
hey everyone! just started learning Visual Basics and it is too good! but am jus stuck on this exercise which i dont know how to do plz could someone help me with this..... i have to write a program that allows to enter 5 student marks into a control array and obtain their total marks, it should also calculate their individual grades from the following
Grade F = Less than 40%
Grade P = Between 40% and 50%
Grade M = Between 50 <70%
Grade D more than 70%
I must also use a sub routine in the solution and a control array in the interface
please help me with this one
hey everyone! just started learning Visual Basics and it is too good! but am jus stuck on this exercise which i dont know how to do plz could someone help me with this..... i have to write a program that allows to enter 5 student marks into a control array and obtain their total marks, it should also calculate their individual grades from the following
Grade F = Less than 40%
Grade P = Between 40% and 50%
Grade M = Between 50 <70%
Grade D more than 70%
I must also use a sub routine in the solution and a control array in the interface
thank's for the info it helps me to get started to my first program...and can you post some examples how to make a code for auto numbering.
I can see alot of work has been put into this tutorial to make it clear to people like me, Good job! keep it up
:)
good tutorial . good job keep it up
give me the syntax of call function
plz explain a simple programme in factorial and fabbonic series
which run without any error
I can\'t believe how many people say that this tutorial is great - have you guys actually read it?
It\'s completely unstructured and full of errors, and I wouldn\'t even call it a tutorial in the first place. Basically this is just a small introduction to some of the widgets, thrown together with a few snippets.
Thanks Aloat For Kinds Of Details But I Have Still a problem That
If I Show Date At Right Side In Form's caption Then What To Do?
2) If I Enter Date Or Name Fields In Text Control Then I Want To Create A Data Report Then What Should I do?
Please Tell Me.
Thanking you
Very much thankful for tutorial.
pls, tell me what is crystal report in vb & how it can be created? Also tell me how print command used in vb?
hi
itsok...thanks coz i now know how to concat..but you can also surf on www.a1vbcode.com...its a site for visualbasic newbies
its a really nice source as well as great guide to those people wh o r new to the the topic,esp begginers point of view.
anyways thanx for the tutorial
I was trying to setup a conversion from Degrees/Minutes/Seconds to Decimals in Visual Basic editor. How do I insert the degree symbolm? I feel really stupid but am really stumped. Using Excel 2007.
Good Article for the bigner in VB6.0
is there some more i need to know about vB,??? i am so interested about this.
pls give some explanation about fabonacci series because i dont how to make a code of it. tnx
it will help me more if you put more exmples and codes so i can try it in my own!
it will help me more if you put more exmples and codes so i can try it in my own!
i will satisfy because i saw matter is very simple.
now i ask how to create a ole.
do you have any examples?
so that we can testrun it...
bleeh!!!!
bleeh!!!!
bleeh!!!!
bleeh!!!!
bleeh!!!!
bleeh!!!!
bleeh!!!!
bleeh!!!!
bleeh!!!!
bleeh!!!!
bleeh!!!!
visit this site instead
http://home.comcast.net/~elsadeks/lang/vb5/index.html
Wow!!!!! my only message is this......what a very nice day??? you know what you`re information is very interesting and very long....That`s all I want tosay thank you so much......
Its good, short and simple to understand the basic idea and defination of a related function
wish i had the software installed in my machine so as to use this simplified and easy to read and understand site efficiently. May you send me one please. I will appreciate. Alex
my email address is: mwotila@yahoo.com
Tanx for the tutorial. It helps me a lot. But i want to know also the small detains next time. Hope you could help me more.
hi can u send me tutorial for game programming using VB 6.0...tnx! it would help a lot...i'm counting on you..plzz..
hi can u send me tutorial for game programming using VB 6.0...tnx! it would help a lot...i'm counting on you..plzz..
This tutorial is good for beginners but i want to know if we write a code to stop the program, save it and close the vb window
Hi! Anyone can please post VB.Net tutorial for beginners. A step by step instructions please. I need it for my research assignment,
thanks
Related Tutorials
Related Source Code
Visual Basic Job Search