First you need a DLL to use your Lpt Port with Visual Basic. My fiend wrote that piece of software for you ( not for windows2000). poort.dll (196kb) and it is legal. Place this DLL in the windows directory. Then you must make a Module to declare your variables. Put this in your Module: Declare Function SchrijfLPT Lib "poort.dll" (ByVal PortAddress As Integer, ByVal PortData As Integer) As Integer Declare Function LeesLPT Lib "poort.dll" (ByVal PortAddress As Integer) As Integer Now you must use them. The data you get and put to LPT Ports are always Binairy. That means : Dec Binair 1 = 0000 0001 Data line 1 will be high 2 = 0000 0010 Data line 2 will be high 3 = 0000 0011 Data line 1 and 2 will be high 4 = 0000 0100 Data line 3 will be high and so on. example 1. The value of textbox 1 will be send to LPT1. to get the value use the function Val and the LPT1 port has the address 888. Make a button and an inputtextbox. Dubbelclick at the button. Write the following text: Dim answer as integer answer = SchrijfLPT( 888 , val(text1.text))
vbprog1.zip ( 2 kb ). example 2. The value of LPT1 will be put in Textbox 1. to get the value use the function LeesLPT . Make a button and an inputtextbox. Dubbelclick at the button. Write the following text: text1.text = str$(LeesLPT( 888 )) Some one has send me this program port.dll . I don't know if it's legal. port.zip(26KB) The declaraions are in the .bas file. The next program i have write for you is vbprog3.( 29 KB ) You can see on your screen 12 lamps and you can click on one of the lamps. When you do that you will see that one of the pins of your lpt port wil be high. Look to the program source and see how easy it is. |