Eerst en vooral dit:
Uitzicht programma:
Hardware:
Programma code:
Module:
Public Declare Function Inp Lib "inpout32.dll" _
Alias "Inp32" (ByVal PortAddress As Integer) As Integer
Public Declare Sub Out Lib "inpout32.dll" _
Alias "Out32" (ByVal PortAddress As Integer, ByVal Value As Integer)
Public Declare Sub Sleep Lib "Kernel32" (ByVal dwMilliseconds As Long)
Form:
Dim code As Single
Private Sub Form_Load()
code = 0
txtUitgangen.Text = Str(code)
Port1 = 888
Out Port1, code
End Sub
Private Sub Form_Unload(Cancel As Integer)
code = 0
Port1 = 888
Out Port1, code
txtUitgangen.Text = Str(code)
End Sub
Public Sub Check1_Click()
If Check1.Value = Checked Then
code = code + 1
Port1 = 888
Out Port1, code
txtUitgangen.Text = Str(code)
shp1.BackColor = &HFF&
Else
If Check1.Value = Unchecked Then
code = code - 1
Port1 = 888
Out Port1, code
txtUitgangen.Text = Str(code)
shp1.BackColor = &H0&
End If
End If
End Sub
Public Sub Check2_Click()
If Check2.Value = Checked Then
code = code + 2
Port1 = 888
Out Port1, code
txtUitgangen.Text = Str(code)
shp2.BackColor = &HFF&
Else
If Check2.Value = Unchecked Then
code = code - 2
Port1 = 888
Out Port1, code
txtUitgangen.Text = Str(code)
shp2.BackColor = &H0&
End If
End If
End Sub
Public Sub Check3_Click()
If Check3.Value = Checked Then
code = code + 4
Port1 = 888
Out Port1, code
txtUitgangen.Text = Str(code)
shp3.BackColor = &HFF&
Else
If Check3.Value = Unchecked Then
code = code - 4
Port1 = 888
Out Port1, code
txtUitgangen.Text = Str(code)
shp3.BackColor = &H0&
End If
End If
End Sub
Public Sub Check4_Click()
If Check4.Value = Checked Then
code = code + 8
Port1 = 888
Out Port1, code
txtUitgangen.Text = Str(code)
shp4.BackColor = &HFF&
Else
If Check4.Value = Unchecked Then
code = code - 8
Port1 = 888
Out Port1, code
txtUitgangen.Text = Str(code)
shp4.BackColor = &H0&
End If
End If
End Sub
Public Sub Check5_Click()
If Check5.Value = Checked Then
code = code + 16
Port1 = 888
Out Port1, code
txtUitgangen.Text = Str(code)
shp5.BackColor = &HFF&
Else
If Check5.Value = Unchecked Then
code = code - 16
Port1 = 888
Out Port1, code
txtUitgangen.Text = Str(code)
shp5.BackColor = &H0&
End If
End If
End Sub
Public Sub Check6_Click()
If Check6.Value = Checked Then
code = code + 32
Port1 = 888
Out Port1, code
txtUitgangen.Text = Str(code)
shp6.BackColor = &HFF&
Else
If Check5.Value = Unchecked Then
code = code - 32
Port1 = 888
Out Port1, code
txtUitgangen.Text = Str(code)
shp6.BackColor = &H0&
End If
End If
End Sub
Public Sub Check7_Click()
If Check7.Value = Checked Then
code = code + 64
Port1 = 888
Out Port1, code
txtUitgangen.Text = Str(code)
shp7.BackColor = &HFF&
Else
If Check7.Value = Unchecked Then
code = code - 64
Port1 = 888
Out Port1, code
txtUitgangen.Text = Str(code)
shp7.BackColor = &H0&
End If
End If
End Sub
Public Sub Check8_Click()
If Check8.Value = Checked Then
code = code + 128
Port1 = 888
Out Port1, code
txtUitgangen.Text = Str(code)
shp8.BackColor = &HFF&
Else
If Check8.Value = Unchecked Then
code = code - 128
Port1 = 888
Out Port1, code
txtUitgangen.Text = Str(code)
shp8.BackColor = &H0&
End If
End If
End Sub
Public Sub cmdAan_Click()
Check1.Value = Checked
Check2.Value = Checked
Check3.Value = Checked
Check4.Value = Checked
Check5.Value = Checked
Check6.Value = Checked
Check7.Value = Checked
Check8.Value = Checked
code = 255
Port1 = 888
Out Port1, code
txtUitgangen.Text = Str(code)
End Sub
Private Sub cmdUit_Click()
Check1.Value = Unchecked
Check2.Value = Unchecked
Check3.Value = Unchecked
Check4.Value = Unchecked
Check5.Value = Unchecked
Check6.Value = Unchecked
Check7.Value = Unchecked
Check8.Value = Unchecked
code = 0
Port1 = 888
Out Port1, code
txtUitgangen.Text = Str(code)
End Sub
Private Sub cmdIngang_Click()
Dim PortNum As Single
PortNum = Inp(889)
txtIngangen.Text = Str(PortNum)
End Sub
Dit geheel samen met de inpout.dll kan men hier downloaden.
Nu men heeft in deze schakeling 5 ingangen. Nu zou ik graag op myn forms 5 labels maken waarin een getal komt te staan. Dit getal zou tonen hoeveel keer ik elke ingang appart heb bediend. Kan iemand my helpen?
Greetz
Ter verduidelijking, later zullen deze schakelaars vervangen worden door een externe pulsgenerator. Iemand die my aub kan helpen?
iets van
oldvalue = port
loop
newvalue = port
until newvalue <> oldvalue
select case (oldvalue - newvalue)
case 128
blabla
case 64
blabla
end select
Thnx voor je respons makker, kzal dit een van deze dagen uitchecken.
Anyway ikzelf heb dit gedaan:
Heb denk ik wel een grote omweg gemaakt maar ik ben er nu ook geraakt. Maar ik ga wel jou methode probere te gebruike omwille van het overzicht!
Indien het lukt of ik heb nog problemen, ik laat het wel weten in de topic. greetz!