visual basic programming language ppt and introduction to visual basic 6.0 programming ppt and visual basic powerpoint samples
Visual Basic ProgrammingHProgramming for the Windows User
Interface is extremely complicated.
HOther Graphical User Interfaces (GUI) are
HVisual Basic provides a convenient method
for building user interfaces.
HVisual Basic can interface with code written
in C, for efficiency.
Why Visual Basic?HVisual Basic is not, a powerful
programming language that enables you to
do anything you want.
HVisual Basic is not, elegant or fast.
HVisual Basic is not, a replacement for C.
HVisual Basic is not, anything like any other
programming language you have ever used.
What Visual Basic is notHYou draw pictures of your user interface.
HYou draw buttons, text boxes, and other
HYou add little snippets of code to handle the
HYou add initialization code, usually as the
HIf you like, you can code more complex
functions. (But many do not.)
When You Program in VB:Here
The Visual Basic InterfaceSelect A Control From Here
Then Draw the control on the form
(Click on the appropriate button)
Drawing The ProgramPictures
And the List Goes On and On ...
Data Base Access
Circles and Stuff
Types of ControlsAdd Code
A Simple ProgramControl
Select New Value From
Type In New Value, or
Click on Property, and
For Currently Selected
List of Properties
The Properties WindowControl
What to Do When It Happens
You must Write
Adding CodeHComplex Controls Have:
Many Types of Events for Program Interaction
Values Are Assigned to Them
Properties that Cause Actions When
Properties to Execute Commands
More Complex ControlsHWrite a DLL in C
HUse the _export Property on Appropriate
HWrite Visual Basic Definitions for each
HAdd VB Definitions to The (general)
section of the VB Program
HUse Functions as if they were VB functions
Using C CodeC:
long FAR PASCAL _export HexToLong (char Hex)
Declare Function HexToLong Lib “ FIRSTONE.DLL”
(ByVal InString As String) As Long
Argument Name in VB is arbitrary.
The Lib keyword Must Give The Name of the Library.
Function Name Must Be The Same in Both Declarations.
C Definition vs. VB DefinitionHIt is sometimes difficult for VB to FIND the
HIf this occurs, copy the .DLL file to the
HRemember to Delete the file when you are
A (Very Annoying) ProblemH Some Versions of VB do not allow DLL
function definitions in the (general) section
of a form.
HTo Get Around this Problem, Create a new
Module (File Menu)
HAdd the declarations to the (general) section
of the module
HYou can add your own VB functions to the
(general) section of a form or a module.
Alternative MethodsHAll Functions are Global in VB
HVariables are declared using the syntax:
–Dim A,B,C As Type will work, but gives
HMost Common Types: Integer, String, Long
Every variable must have a type
Dim Name As Type
Syntax ConsiderationsHUse Integers for Booleans
–As in C, 0 = False, everything else = True
HAssignments are the same as in C
HThe Val function converts strings to integers
HThe Format function converts integers to
True = -1, False = 0
Symbolic constants True and False may be used
More VB SyntaxHAssignments are the Same as in C
HCase is not significant
HThe Usual Operators can be used
–AND is the same as both & and && depending
OR = and
For Variable Names, Case is ignored
Case will be adjusted for you on keywords
VB Statements List of Statements List of Statements
List of Statements
Comparators: =,, , =, =, (not equal)
Connectives: And, Or, Not
DON’T FORGET THE ENDIF
If condition ThenIf condition Then
VB IF StatementsWhile condition do
List of Statements
The VB Manual Recommends a different structure.
Use the alternative if you wish.
VB While Statements