|
Visual Basic example
The Visual Basic example
is slightly more complex because Visual
Basic has no direct equivalent of
OUT in QBasic or _outp() in Visual
C++ . This means you have to write
a DLL or use someone else's . We will
choose the latter .
Download inpout32.zip
Unzip the file and follow
the instructions in the file called
inpout32.txt
Put the inpout32.dll in c:\windows,
c:\windows\system and
your program's default directory to
insure your program can find it.
Now lets create a simple
program to test the simple circuit
. First create a new project and place
2 command buttons on this form , call
one of the buttons LED on and the
other LED off.
figure 1 : Visual
Basic layout

Now enter this in the
general declarations section
Private Declare
Function Inp Lib "inpout32.dll"
_
Alias "Inp32" (ByVal PortAddress
As Integer) As Integer
Private Declare Sub Out Lib "inpout32.dll"
_
Alias "Out32" (ByVal PortAddress
As Integer, ByVal Value As Integer)
Dim Port1 As Integer
Now enter the following in the LEDS
ON command button's click procedure
Private Sub Command1_Click()
Port1 = 888
Out Port1, 1
End Sub
Now enter the following in the LEDS
OFF command button's click procedure
Private Sub Command2_Click()
Port1 = 888
Out Port1, 0
End Sub
Now run your program and test out
the buttons , viola the led switches
on and off .
Download
ledflash.frm
ledflash.vbp
ledflash.exe
|