Design Ideas: February 17, 1994
| Listing 1C++ source code for DLL (Borland C++ compiler) |
|---|
![]() |
| Listing 2VisualBasic location declarations |
To use Inp and Out in VisualBasic, you must tell your program that these operations exist. Use the Declare statements, as Listing 2 shows. Remember that the Out operation is a subroutine because it simply outputs a byte; it returns nothing back to your VisualBasic program. The Inp operation is a function, because it returns a byte from an input port. You use the ByVal keyword to tell VisualBasic that you want it to transfer the actual value, and not a reference or pointer to the value.
In addition, you must explicitly tell VisualBasic where to find the library functions in your DLL. This example assumes the DLL is on a floppy disk in the B drive. You can put the DLL on another drive, but be sure to tell VisualBasic where it is.
Simple VisualBasic program fragments show how to use the Inp and Out instructions. For example, Out 771, 130 sends the value 130 to output port 771 of my PC. On the other hand, A=Inp(769) assigns the byte at input port 769 to variable A. The syntax is exactly the same as in most other Basics. EDN BBS /DI_SIG #1367