Ik probeer met VB 2010 de parallelle poort aan te sturen, alles gaat goed tot nu toe, maar bij IO.dll invoegen krijg ik foutmeldingen.
Module Io
Option Strict Off
Option Explicit On
Module io
Public Declare Sub PortOut Lib "IO.DLL" (ByVal Port As Integer, ByVal Data As Byte)
Public Declare Sub PortWordOut Lib "IO.DLL" (ByVal Port As Integer, ByVal Data As Integer)
Public Declare Sub PortDWordOut Lib "IO.DLL" (ByVal Port As Integer, ByVal Data As Long)
Public Declare Function PortIn Lib "IO.DLL" (ByVal Port As Integer) As Byte
Public Declare Function PortWordIn Lib "IO.DLL" (ByVal Port As Integer) As Integer
Public Declare Function PortDWordIn Lib "IO.DLL" (ByVal Port As Integer) As Long
Public Declare Sub SetPortBit Lib "IO.DLL" (ByVal Port As Integer, ByVal Bit As Byte)
Public Declare Sub ClrPortBit Lib "IO.DLL" (ByVal Port As Integer, ByVal Bit As Byte)
Public Declare Sub NotPortBit Lib "IO.DLL" (ByVal Port As Integer, ByVal Bit As Byte)
Public Declare Function GetPortBit Lib "IO.DLL" (ByVal Port As Integer, ByVal Bit As Byte) As Boolean
Public Declare Function RightPortShift Lib "IO.DLL" (ByVal Port As Integer, ByVal Val As Boolean) As Boolean
Public Declare Function LeftPortShift Lib "IO.DLL" (ByVal Port As Integer, ByVal Val As Boolean) As Boolean
Public Declare Function IsDriverInstalled Lib "IO.DLL" () As Boolean
End Module
End Module
Error 1 'Option' statements must precede any declarations or 'Imports' statements. (2 keer)
Error 3 'Module' statements can occur only at file or namespace level.
Iemand een idee wat ik verkeerd doe?
Maak eens een nieuwe module er plak daar het volgende in:
Public Declare Sub PortOut Lib "IO.DLL" (ByVal Port As Integer, ByVal Data As Byte)
Public Declare Sub PortWordOut Lib "IO.DLL" (ByVal Port As Integer, ByVal Data As Integer)
Public Declare Sub PortDWordOut Lib "IO.DLL" (ByVal Port As Integer, ByVal Data As Long)
Public Declare Function PortIn Lib "IO.DLL" (ByVal Port As Integer) As Byte
Public Declare Function PortWordIn Lib "IO.DLL" (ByVal Port As Integer) As Integer
Public Declare Function PortDWordIn Lib "IO.DLL" (ByVal Port As Integer) As Long
Public Declare Sub SetPortBit Lib "IO.DLL" (ByVal Port As Integer, ByVal Bit As Byte)
Public Declare Sub ClrPortBit Lib "IO.DLL" (ByVal Port As Integer, ByVal Bit As Byte)
Public Declare Sub NotPortBit Lib "IO.DLL" (ByVal Port As Integer, ByVal Bit As Byte)
Public Declare Function GetPortBit Lib "IO.DLL" (ByVal Port As Integer, ByVal Bit As Byte) As Boolean
Public Declare Function RightPortShift Lib "IO.DLL" (ByVal Port As Integer, ByVal Val As Boolean) As Boolean
Public Declare Function LeftPortShift Lib "IO.DLL" (ByVal Port As Integer, ByVal Val As Boolean) As Boolean
Public Declare Function IsDriverInstalled Lib "IO.DLL" () As Boolean
Leime
0 errors! Bedankt 
Edit: Te vroeg gejuicht: "Unable to load DLL 'IO.DLL': Kan opgegeven module niet vinden. (Exception from HRESULT: 0x8007007E)"
De dll staat nochtans wel in de system32 map
[Bericht gewijzigd door T-baev op (82%)]
VB 2010 voegt allemaal vreemde dingen toe altijd. EDIT: Zal vast wel een reden voor zijn maar als het werkt 
Maare, werkt het nu ook nog? 
[Bericht gewijzigd door leime op (30%)]
Op 20 mei 2010 22:03:03 schreef T-baev:
0 errors! BedanktEdit: Te vroeg gejuicht: "Unable to load DLL 'IO.DLL': Kan opgegeven module niet vinden. (Exception from HRESULT: 0x8007007E)"
De dll staat nochtans wel in de system32 map
Moet die DLL niet in bij je EXE staan?
ja, de dll moet in dezelfde map als waar je projectbestanden staan
[Bericht gewijzigd door leime op (27%)]
en als je "Option Strict Off" en "Option Explicit On" wil gebruiken moet je dat boven "module IO"
Option Strict Off
Option Explicit On
Module io
Public Declare Sub PortOut Lib "IO.DLL" (ByVal Port As Integer, ByVal Data As Byte)
Public Declare Sub PortWordOut Lib "IO.DLL" (ByVal Port As Integer, ByVal Data As Integer)
Public Declare Sub PortDWordOut Lib "IO.DLL" (ByVal Port As Integer, ByVal Data As Long)
Public Declare Function PortIn Lib "IO.DLL" (ByVal Port As Integer) As Byte
Public Declare Function PortWordIn Lib "IO.DLL" (ByVal Port As Integer) As Integer
Public Declare Function PortDWordIn Lib "IO.DLL" (ByVal Port As Integer) As Long
Public Declare Sub SetPortBit Lib "IO.DLL" (ByVal Port As Integer, ByVal Bit As Byte)
Public Declare Sub ClrPortBit Lib "IO.DLL" (ByVal Port As Integer, ByVal Bit As Byte)
Public Declare Sub NotPortBit Lib "IO.DLL" (ByVal Port As Integer, ByVal Bit As Byte)
Public Declare Function GetPortBit Lib "IO.DLL" (ByVal Port As Integer, ByVal Bit As Byte) As Boolean
Public Declare Function RightPortShift Lib "IO.DLL" (ByVal Port As Integer, ByVal Val As Boolean) As Boolean
Public Declare Function LeftPortShift Lib "IO.DLL" (ByVal Port As Integer, ByVal Val As Boolean) As Boolean
Public Declare Function IsDriverInstalled Lib "IO.DLL" () As Boolean
End Module
Op 20 mei 2010 22:21:35 schreef T-baev:
Daar staat hij nu en nog steeds krijg ik die foutmelding.
Wat is de rest van je code? Misschien ligt het daar aan.
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub BTNdata0_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNdata0.Click
Call PortOut(&H378, 1)
End SubPrivate Sub btndata1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btndata1.Click
Call PortOut(&H378, 0)
End SubPrivate Sub lblWaardeLPT_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblWaardeLPT.Click
lblWaardeLPT.Text = PortIn(&H378)
End Sub
End Class
Met de map met prokectbestanden bedoel je toch de map waarim het programma is opgeslaan he?
Je kan ook eens proberen om de dll aan je project toe te voegen, dit doe je door in je "solution exporer" rechtsklik op je project naam en dan add, exisiting item.
En als je nou via een private sub werkt?
Heb je al, ik moet beter opletten
(eerst als edit, toch maar even als nieuwe post)
[Bericht gewijzigd door leime op (43%)]
Op 20 mei 2010 22:27:11 schreef T-baev:
[...]Met de map met prokectbestanden bedoel je toch de map waarim het programma is opgeslaan he?
De dll zou moeten staan bij E:\Documents\Visual Studio 2010\Projects\PROJECTNAAM\PROJECTNAAM\bin\Debug\HIER DLL
de dll toegevoegd via existing item, hetzelfde verhaal.
In de map visual studio 2010 zit geen map met de naam projects.
EDIT: Ik heb de map projects gevonden en deze is leeg.
[Bericht gewijzigd door T-baev op (19%)]
En als je die Private sub nou in de module zet? en dan met call werkt.
Ik heb nog ergens werkende modules op de computer, mocht je die willen kan ik ze morgen eens opzoekken, het is me nu te laat
Pff, wat posten jullie snel
Oke, ik heb nu een andere IO.dll gesownload en in bin/debug gezet en nu werkt het. Het was gewoon een slechte dll.
Progger
GMT+1
ohw, grappig
normaal zet je de DLL in windows/System32. als die daar niet in staat zal hij zoeken in de map waar het exe bestand ook in staat (of andersom). meestal is dit je projectmap/bin
Progger
GMT+1
dan is deze wellicht niet geregistreerd. iets met start->uitvoeren->RegSvr32 C:\Windows\System32\iodll.DLL
Ik heb 16 "buttons", alles werkt tot nu toe, alleen kan er maar 1 knop tegelijk ingedrukt zijn. Nu moeten er natuurlijk meerdere uitgangen tegelijk hoog gemaakt worden, hoe kan ik dit doen?
Progger
GMT+1
heb je 16x dit?
Private Sub BTNdata0_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNdata0.Click
Call PortOut(&H378, 1)
End Sub?
kun je dan niet beter zeggen, je maakt 1 functie die de waarde bijhoud, en die laat je aanroepen door iedere knop. dan doet hij een XOR met je waarde (bijv. knop 3 is 4, 4=8, 5=16) en dat schrijf je naar de poort. kan je opslaan in een globale variabele of gewoon form1.tag 
nog netter is het als je met een control array werkt.
Sorry, maar dit is latijn voor mij, ik heb nog niet 16 keer dat, want ik heb alleen nog maar de layout en de code voor 2 knoppen. Maar ik was idd van plan om dat 16 keer te doen ja.
Progger
GMT+1
ben een beetje verwend, want in delphi is dat heel simpel.
maar je moet eens kijken wat een XOR doet, de eXclusive OR.
a|b|result
-+-+------
0|0|0
1|0|1
0|1|1
1|1|0
-+-+------moet in visual basic ook kunnen.
als je dus een 7 hebt (A=00000111) en daarop een 2 XOR'd (B=00000010) is het resultaat 5 (00000101) (op iedere bit word de XOR bewerking gedaan)
dus als jij bij iedere knop een waarde meegeeft (1,2,4,8,enz.) kan je dus met de huidige waarde + een XOR de juiste bit omzetten (iedere bit is tenslotte 1 poort)
alleen kun je er maar 8 doen, omdat dat de grote van de poort is (excl controle signalen)