Syntax Considerations
H All Functions are Global in VB
H Variables are declared using the syntax:
– Dim <Name> As <Type>
– Every variable must have a type
– Dim A,B,C As <Type> will work, but gives
weird results
H Most Common Types: Integer, String, Long
,Alternative Methods
H Some Versions of VB do not allow DLL
function definitions in the (general) section
of a form.
H To Get Around this Problem, Create a new
Module (File Menu)
H Add the declarations to the (general) section
of the module
H You can add your own VB functions to the
(general) section of a form or a module.
,A (Very Annoying) Problem
H It is sometimes difficult for VB to FIND the
.DLL file.
H If this occurs, copy the .DLL file to the
WINDOWS directory.
H Remember to Delete the file when you are
done.
, C Definition vs. VB Definition
C:
long FAR PASCAL _export HexToLong (char *Hex)
VB:
Declare Function HexToLong Lib “FIRSTONE.DLL”
(ByVal InString As String) As Long
Function Name Must Be The Same in Both Declarations.
The Lib keyword Must Give The Name of the Library.
Argument Name in VB is arbitrary.
H All Functions are Global in VB
H Variables are declared using the syntax:
– Dim <Name> As <Type>
– Every variable must have a type
– Dim A,B,C As <Type> will work, but gives
weird results
H Most Common Types: Integer, String, Long
,Alternative Methods
H Some Versions of VB do not allow DLL
function definitions in the (general) section
of a form.
H To Get Around this Problem, Create a new
Module (File Menu)
H Add the declarations to the (general) section
of the module
H You can add your own VB functions to the
(general) section of a form or a module.
,A (Very Annoying) Problem
H It is sometimes difficult for VB to FIND the
.DLL file.
H If this occurs, copy the .DLL file to the
WINDOWS directory.
H Remember to Delete the file when you are
done.
, C Definition vs. VB Definition
C:
long FAR PASCAL _export HexToLong (char *Hex)
VB:
Declare Function HexToLong Lib “FIRSTONE.DLL”
(ByVal InString As String) As Long
Function Name Must Be The Same in Both Declarations.
The Lib keyword Must Give The Name of the Library.
Argument Name in VB is arbitrary.