This is very small program which explains how the database is connected to the visualbasic 6, If you run this program, the data EmpName in the first record of the table 'EMP' will be displayed in the textbox.
step 1: create a form.
step 2. In that form create a textbox with name 'text1'
step 3. write the following code under 'GENERAL'
Dim Rs as New ADODB.Recordset
step 4: write the following code under 'FORM'
Private Sub form_load()
call dbOpenCon
sql="select * from emp"
rs.open sql.con,adOpenDynamic,adLockpPessimistic
text1.text=rs!EmpName
End Sub
step 5: Create a module and save as module1.bas . This module should contain
the following code:
Public con as New adodb.connection
Public sub dbOpenCon()
srconnection="provider=microsoft.jet.oledb.4.0;" &_
"data source=" & app.Path & "emp.mdb;persist security ifo=false'
con.ppen strconnection
End Sub
step 6. Now run this program
===================================
each statement should be writen in a single line. But if the length of a statement is very long,
we would like to jump to the next line. How to handle this situation:
x="Once upon a time I went to Newyark"
The above one line statement can be writen in two lines as shown below:
x="Once upon a time I " &_
"went to Newyark"
another example: in this case no double-qoute is invoved:
form1.designationTextbox.Text=form1.post.Textbox.text
the above single line statement can be writen in two lines as shown here:
form1.designationTextbox.Text=form1. _
post.Textbox.text
=====================================================
For learning VB6, you should create some basic projects for yourself.
http://www.vb6.us/ is a very good site
for beginners.
FOLLOWING ARE SOME OF THE VB6 PROGRAMS FOR BEGINNERS(complete source code is given)
This sample source code shows you exactly how
to create a PDF file from within your VB application with out having
to buy a third party control or dll. It gives an example of creating
a PDF and adding text to it.
This full program is a simple calculator like
what comes with windows. It demonstrates many controls and commands.
See how to write a full working version of the
Concentration game.
Learn how to create a full hangman game with
graphics. This program uses forms, timers, graphics, and many other
common controls.
This code shows a full tic tac toe. It uses
forms, graphics, a simple AI algorithm, and other fun game stuff.
This is a simple game that also shows how to
do a fun cryptography method. It also teaches you forms, graphics and
other basic VB controls.
This program converts an integer in the range
of 1 through 3999 to its equivalent in Roman numerals. It also converts
a Roman numeral string to its decimal equivalent.
See how to build an advanced client server chat
like program that allows multiple connections (like IRC) using the Winsock
control.
Would you like to write your own chat or IM
program? This sample demonstrates how you can use the VB6 Winsock control
to build a simple client server application.
Every great game keeps tracks of users high
scores and displays them. See how to do just that.
Ever wanted to write your own scripting language?
While this source will get you started. See how to use dynamic classes
to create a runtime class browser.
Take a look at this example code to see how
to read data from windows resource files and use it in DirectX - specifically
Direct Draw.
See how we can build of off Visual Basic 6's
way of storeing data and information in .frx files using property bags.
Use the binary AND and OR operators to keep
track of game character attributes.
See how to do all sorts of things with bitmap
files. This code demonstrates how to use and manipulate windows bitmaps
at the lowest level.
See how to use binary operators to store a characters
attributes in a binary way to use less memory for your game development
This source demonstrates how to map 3d coordinates
in a way that allows the user to click on them with his mouse using
DirectX 8.
Instead of putting a frame cap on your game
this source code shows you how to get your max FPS by using Time Based
Modeling.
If you want enemies to seek after your player
(like ghosts after pacman) or you want enemies to run from your player
(like when pacman eats a pill) then you must master the AI seeking and
fleeing algorithms.
In any good game we must detect when objects
have collided. This turns out to be pretty simple. See how to do both
rectangular and circular collision detection.
See an example of how we can use XOR functions
to do simple encryption on strings. Very useful for simple game high
score encryption.
There are times in game development where we
need to have a bunch of objects behave like a flock. With a little math
we can simulate the behavior of a flock of animals.
Have you ever wanted to display your program
in the system tray by the clock. This code demonstrates how you can
do just that using Windows API calls only.
This sample demonstrates how to call the FlashWindow
Win32 API from within your program. Use this to get the end user's attention.
See an example of menus being added dynamically.It
does this simply by using menu control arrays.
A full working application that mimics a cellphone
touch-pad. It demonstrates how to use control arrays. It also uses the
timer control.