Controls Guide


This Visual Basic 6 guide takes you step by step through tutorials on this site that will show you how to use all the main VB6 controls. The best way to navigate through the guide is by using the links on the left. Or you can use the links below and then hit your browser's back button. Each link will take you to a different tutorial on this site that will teach you the next step you need to know to learn.

Here are some optional exercises you can try yourself or simply download them and look at the source code. They all use things listed above.

If you enjoyed this post, subscribe for updates (it's free)

how to make a memory game on vb6


i want the codes to make a memory game with 12 fields
please send it to me as soon as possible

VB6 + AutoCAD

Hey guys! These tutorials are really good! But I still have some problems....
My "task" is to input some data in AutoCAD (make some drawings) , but my input must be by VB6... In other words, i'm trying to draw some figures (simple ones) in AutoCAD but inputting then in a VB environment. Does someone know how to do it?

Thanks a lot!


can any one tell me how can I make navigation/consistency server between client and server

run time error '3343'

How to connect MS access database to VB6.0?

when i run the project this error will occurs..
Run time error '3343'
Unrecognized database format 'D:\..\..\.mdb'.

please suggest the code..

runtime error?

If you are using MS ACCES 2007 or higher... you must save it in MS ACCESS 2000 format enable to save .mdb files...

If you are saving the db first, all you have to do is go to to office button (where you can find at the top left corner)>click save as>ACCESS 2000 DATA BASE>(filename).mdb

Connection ADODB Control

Make sure it is choosing active x control 6.0 in refrence project after it makes a declaration
Dim conn as new ADODB.Connection
Dim rs as new ADODB.Recodset
In the active form "Load" wrote ("Provider = Microsoft.Jet.OLEDB.4.0; Data Source = C \ database.mdb")
rs.CursorLocation = SetUserLocation
rs.Open "Database Table", conn, adOpenDinamic, adLockOptimistic
set DataGrid1.DataSource = rs

Oppen the DataBase and Save

Oppen the DataBase and Save as 97-2003 format

Same here

I have tried different versions of Access. Pre 2000, 2000-2003, and up to current versions. I get the same error 3343 when it tries to open the database. What component or item am I not including? Where do I add it? Why won't it recognize it? It is an extremely simple database to test opening with. In most of the tutorials, it is so simple and easy that everyone seems to take it for granted like saying "Turn on your computer to begin." But for some reason, it is the one break in the wire for me keeping the power off. I have added all the database sounding components I could find and it just won't open. I have lost too much time beating my head against this now bloody brick wall. I need to move forward beyond this baby step. HELP!

I Figured it out... I think.

Using the DataProject to do database access assumes you are using the OS Database access controls. It takes the default priority. The command to open a database file conflicts with this connection. When you have the designer component loaded into the project, it causes the error. The solution is to choose which way you want to connect to the database. Using the OpenDatabase command requires that you simply remove the designer components from the project that ate in conflict. To find them quickly, look in the window pain in the upper right corner for the component tree under where you choose the form view. You will see the tree with the form and then, you will see the other data components below that. It is the connection that is messing us up.

It is one of those things that is a baby step usually done automatically by VB Design Studio, so there is practically no documentation about it. Everyone that understands it assumes it is just too easy to document. So, it is one of those things that will give you a sleepless night if you ever have problems with it.

Good luck!

Plz help..

what are the codes to connect combo box and textbox to search the files?

Filter ADODB

create a textbox named after it wrote text_filter
rs.filter = "filter grade = '" & text_filter & "'"

rs is the declaration for ADODB recordset


What kind of file you need to search? Do you need to search files in a specific folder? Or need to find text in Combo box.


anyone can tell me how to connect biometrics code in the vb 6.0

login page

how to create login page in vb also
i need source code details about language

Login IF Funcition

Use funcition if the string "And"
create 2 textbox named "user" and "password"
write code
if me.user.text = "Your Name" And me.password.text = "Your Password" then
unload me
intResponse = MsgBox ("Data are not approved are sure you want to repeat", vbQuestion + vbYesNo, "Notice")
if intResponse = 6 then
load me
end if

6 = value of vbYes if active

msflaxgrid control



i want to record the phone conversation using modem in my pc...........


hey guys ive been looking alll over the internet but i cant find how to do this.

i want to do a simple thing like a messagebox that says "press y to continue"
this is what i have so far:

Set wshShell =wscript.CreateObject("WScript.Shell")

msgbox "press y to continue"

now what do i do??


Instead of the msgbox try these

TmpFlag = MsgBox("Press Yes to continue", vbYesNo + vbDefaultButton2)
If TmpFlag = vbYes Then
'write your code
End If



data control using ms access 97

pp i i am using 3 data control in a form,
datdata control1 - record source - itemmaster
datdata control2 - record source - employee
datdata control3 - record source - transaction
h here i getting values of itemname(using combo) - cmbitemname & relevent available qty ( text box ) - txtqty from data control1 using item master table,
entering required qty - txtrqty ( text box )
s secondly using data control2 i getting values of empname ( using combo ) - cmbempname & relevent departmnet ( text box ) txtdepartment from employee table.
now i am processing - select the itemname from table item master, revelent quantity will shown in a available qty ( txtqty ) & entering the required quantity in the test box ( txtrqty ), now here the balance qty should be updated in the item master table - field - txtqty also i have to show the process & save the details in transaction table with the fields - item name, rqty ( required qty ), employee name & department.

open word document, find string and highlight it through vb prog

i want to write a programme which doed follow things
1) from vb form directly open word document
2) find the specified string on that document
3) highlight string on docum,ent
can some body helps me
i write code like this

Private Sub lblVisitReport_Click()
Dim objword As Word.Application
Set objword = New Word.Application
objword.Visible = True
objword.Documents.Open (gReportpath)

findText = txtSchemeDes.Caption

If objword.selection.Find.Execute(findText) = True Then
MsgBox "text found", vbCritical + vbOKOnly, sTitle
MsgBox "text Not found", vbCritical + vbOKOnly, sTitle
End If

End Sub

by running it opens vb document but could not find sting and highlight
pls help
thanks in advance

open many forms in same project

whenever i save a project (it is saved ) but when m trying to open the project all the forms are splitted apart and all opens in different vb application can u help me out :
1) i want to open all the form in the same vb project window(not splitted apart which opens in different vb application).
2) In ADODC connection is it necessary to connect with (MS access or sql server) each time we start the project ?

Manipulating Notepad once open, using Shell or ShellExecute.

How to ShellExecute (API call) Notepad (or a like program) and manipulate it by navigating to the bottom of existing data, subsequently entering a Date/Time Stamp, as in a .LOG entry format.

And alternately, the same with a Text Box control.


Tutorial on MshFlexGrid

Dear Sir,

Your tutorials are very understandable and good so can you please write tutorial on using MshFlexGrid.

Uday Kumbhar

pls i need help!!!

please, can someone help me out with d vb codes required to minimize any form of Boolean expression. 10ks

calling other windows program...

how can i call and access calculator, calendar or other windows program using vb? i really need help..

call another window programe from vb

use the shell function for execute the any exe file in windows

Serial coding (Transreceiver)

I need help in coding a serial communication in vb 6 . Please help its urgent. how can i send an receive an array of bytes and than transmit it.

need help with vb studio 2005

I need help in connecting vb studio 2005 with Ms access 2000.............thank you in advance

Pls help me

how to connect vb6 to ms access or mysql using adodb, and a sample code of user login using database ms access..........plssss help mee thanks a lot!... -josh--



simple programme

want to create a simple programme that keeps infromation entered daily, can somebody help via the email

tab keypress

what is the code of this...using the tab if i press it the focus transfer to the next textbox..pls help me



keypress for numbers?

can you pls tell me that how to restrict a text box that enters only numbers 0-9

On Error Resume Next If

On Error Resume Next
If KeyAscii < Asc(0) Or KeyAscii > Asc(9) Then
If KeyAscii = 8 Then
Exit Sub
End If
KeyAscii = 0
End If

How do i make a process box

How do i make a process box. I really need to no!!!

How do I return cursor location (Line, Col.) in a Rich Text Box

How can I return the cursor location (Line,Col.#) in a Multiline Rich Text Box?
Is there a better way than using SelLength? or the SelChange Event? or
Where can I get a complete tutorial on Rich Text Box? Im talking beginer to adv.
The works. I want to creat a text editer in a MDIform and I soooo need help.

Thanks for any help I can get.

can u help on how to access

can u help on how to access database from the ms excel???plssss....thanks


Hi, since everyone is asking everything i'm going to ask too :)

I have been wondering How to find modules and drivers to program input/output on PCI bus. And if there is any way to see a sample code of using these two in typing a program to send/recieve data through PCI on motherboard.

So far I have used inpout.dll with inpoutv4.bas and port.dll with ports.bas and I've used it to make a program to control LPT for use with a 2X16 lcd display.
Now I want to use a PCI or atleast ISA to control a memory chip with 16 adress ports because LPT is limited with 8 (max 12) output pins.

I have been doing this with everything that I have at home, so I don't want to buy software or hardware wich is too expencive for my standards.

I have everything set and waiting for the drivers and modules and I am wery gratefull for any kind of info on how to do this.

BTW if anyone has any questions about making small and usefull aplications in VB send questions to, I don't promise but may be of help.

Help me!!!!

A textbox is on a form. User will type his/her name in that textbox. But ny problem is when user type the text in which the first alphabet of the text which he/she shall type , the first alphabet will be automatically capital.How can I do it?????????????????

upper case first charcter in text box

just type following code on textbox lostfocust event for want u result..

Private Sub txte_LostFocus(Index As Integer)
If Index = 3 Then
txte(3).Text = UCase(Left(txte(3).Text, 1)) + LCase(Mid(txte(3).Text, 2, Len(txte(3).Text)))
End If
End Sub


Private Sub txtFname_Change()
txtFname.SelStart = Len(txtFname) + 1
txtFname = StrConv(txtFname, vbProperCase)
End Sub

This is an easy one......

This is an easy one...... try this code

Private Sub Text1_KeyPress(KeyAscii As Integer)
If Len(Text1.Text) = 0 Then
KeyAscii = Asc(UCase(Chr(KeyAscii)))
End If
End Sub


How can I connect VB6 project with Microsoft Access by ADODB? PLZ... Help me soon...

connecting vb6 with ms-access via adodb

there are lots of options to connect vb6 apps to an ms-access dbase via adodb. here is a sample procedure to do it.
activate the adodc tool at the toolbox. right click toolbox and click components. then at the control tab choose ado data control 6,afterwards click apply button and then the ok button.

now put adodc tool at the form, and right click it. and at the drop list option choose adodc properties. then choose "use connection string" option and click build button. afterwards choose dbase engine to be use and set the dbase source file. then test the said connection. else if not success check the engine youre using. and also the soure dbase.
now create a connection module.

check this sample connection module ---------- >>>
Option Explicit

Public rs As ADODB.Recordset
Public con As ADODB.Connection
Dim c

Public Sub db()
Set rs = New ADODB.Recordset
Set con = New ADODB.Connection
c = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\dbase\posbase.mdb;Mode=ReadWrite;Persist Security Info=False"
con.ConnectionString = c
End Sub

and your main app you can now use the db object and its rs, con functions..
use SQL statement to open a connection"

need to open multiple autocad drawings

Dear All,
I have a 20 autocad drawing files in a folder.
I have the list of the drawing with its path name and file name in the excel sheet.
I need to create a vb program so that it opens all the 20 drawings in autocad application one by one and give print and close the drawings.
please provide me a simple program for that, becasue i am not well versed in VB programming... Thanks in advance.

Restrict a textbox to enter alphabets only

pls tell me that how to restrict a text box to enter only alphabets like A-z, or a-z

to resticate alpabets certain text box

Private Sub Text1_KeyPress(KeyAscii As Integer)
Dim i, j As Integer ' their is many other ways i find this better

For i = 65 To 90 ' 65 to 90 is Ascii value of captial "A" to "Z"
If KeyAscii = i Then
KeyAscii = 0 ' make ascii value null
End If
Next i ' do it for next number

For j = 97 To 122 ' 97 to 122 is ascii value of small "a" to "z"
If KeyAscii = j Then
KeyAscii = 0 ' make ascii value null
End If
Next j 'for other info contact

End Sub ' thanks to u RONY CHAKRABORTY

In the keypress event for

In the keypress event for the textbox, add the following code:

    If (KeyAscii >= 65 And KeyAscii <= 90) Or (KeyAscii >= 97 And KeyAscii <= 122) Then ' 65-90 = A-Z, 97-122 = a-z
        Exit Sub
    ElseIf KeyAscii = 8 Then ' allow backspace
        Exit Sub
    ElseIf KeyAscii = 13 Then ' allow "enter" key
        Exit Sub
    Else ' kill everything else
        KeyAscii = 0
    End If

Hope That Helps!


How to to create multiple forms in run time

Can anyone please help me How to to create multiple forms in run time




thankx Lot Dear Sir I got more from your page. Few codes did lot.

Thank you very much!

it help me a lot, ... :-)