[VB6] Waarden maskeren

Pagina: 1
Acties:

  • [TazZ]
  • Registratie: April 2001
  • Laatst online: 25-06-2025
Voorheen stuurde ik mijn parralelle interfacekaart (8 relais en 4 ingangen) aan met turbo pascal. Ik ben nu overgestapt op Visual Basic 6 vanwege de mooie interfaces die je aan zoiets kunt hangen.

Nu is het aansturen van de relais helemaal geen probleem, maar het probleem ontstaat wanneer ik de schakelaars wil uitlezen.

Voorheen maskeerde ik waardes van de schakelaars door in pascal de volgende code te gebruiken:
code:
1
2
3
4
if port[$379] and 8 = 8 then switch1 = 1
if port[$379] and 16 = 16 then switch2 = 1
if port[$379] and 32 = 32 then switch3 = 1
if port[$379] and 64 = 64 then switch4 = 1

hoe doe ik dit in vb?

If it ain't broke, fix it till it is...


Verwijderd

Die manier werkt toch ook gewoon in vb?

Een AND operator in pascal is de zelfde operator in VB

  • pkouwer
  • Registratie: November 2001
  • Laatst online: 07-10-2025
zekers te weten dat maskeren op deze manier ook in VB werkt. idd maskeren in VB = maskeren in Pascal = maskeren in Delphi = maskeren in weet ik veel wat

  • [TazZ]
  • Registratie: April 2001
  • Laatst online: 25-06-2025
nope, gaat niet in vb, dan pakt hij altijd de waarde die achter and staat... daarom heb ik het hier ook staan... :)

ik heb het al op deze manier geprobeerd...

If it ain't broke, fix it till it is...


  • BdR
  • Registratie: Juni 2001
  • Laatst online: 03-09-2025

BdR

TV is gooder then books

heb je et ook met haakjes geprobeerd?
code:
1
if (port[$379] and 8) = 8 then switch1 = 1

of misschien port[$379] eerst in een tijdelijke variabele doen, en daar dan AND mee doen?
offtopic:
00fly747 wat is dat voor een icoontje, een vreemde Bert en Ernie met guns?

mijn web games -> Impossible Snake 2 :: Impossible Snake :: Snake Slider


  • whoami
  • Registratie: December 2000
  • Laatst online: 20:22
Ehm, even een vraagje, maar waarom doe je dat met 4 if's?

Die 2de conditie in al die if's, zullen altijd een True opleveren en die eerste conditie is ook altijd dezelfde.

https://fgheysels.github.io/


  • [TazZ]
  • Registratie: April 2001
  • Laatst online: 25-06-2025
in pascal leverde dit het goede effect op, die 2e conditie wordt in pascal niet gezien zoals in vb, daarom werkt deze code niet onder vb, wel onder pascal... maar ik denk dat ik het al gevonden heb... bedankt iig... (vbcity wist de oplossing)

If it ain't broke, fix it till it is...


  • whoami
  • Registratie: December 2000
  • Laatst online: 20:22
Op woensdag 10 juli 2002 12:46 schreef -LoOneY- het volgende:
in pascal leverde dit het goede effect op, die 2e conditie wordt in pascal niet gezien zoals in vb, daarom werkt deze code niet onder vb, wel onder pascal... maar ik denk dat ik het al gevonden heb... bedankt iig... (vbcity wist de oplossing)
Post ze hier dan ook even, dan hebben andere mensen er ook wat aan.

https://fgheysels.github.io/


  • [TazZ]
  • Registratie: April 2001
  • Laatst online: 25-06-2025
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
Private Declare Sub vbOut Lib "WIN95IO.DLL" (ByVal nPort As Integer, ByVal nData As Integer) 
Private Declare Sub vbOutw Lib "WIN95IO.DLL" (ByVal nPort As Integer, ByVal nData As Integer) 
Private Declare Function vbInp Lib "WIN95IO.DLL" (ByVal nPort As Integer) As Integer 
Private Declare Function vbInpw Lib "WIN95IO.DLL" (ByVal nPort As Integer) As Integer 

Private Const BitMask_0 = &H1 'not used 
Private Const BitMask_1 = &H2 'not used 
Private Const BitMask_2 = &H4 'not used 
Private Const BitMask_3 = &H8 
Private Const BitMask_4 = &H10 
Private Const BitMask_5 = &H20 
Private Const BitMask_6 = &H40 
Private Const BitMask_7 = &H80 

Private Const DataAddress = &H378 
Private Const ControlAddress = &H37A 
Private Const StatusAddress = &H379 

Private StatusBit_0 As Boolean 'not used 
Private StatusBit_1 As Boolean 'not used 
Private StatusBit_2 As Boolean 'not used 
Private StatusBit_3 As Boolean 
Private StatusBit_4 As Boolean 
Private StatusBit_5 As Boolean 
Private StatusBit_6 As Boolean 
Private StatusBit_7 As Boolean 

Private Sub Command1_Click() 

    Dim bitVal_0 As Byte 
    Dim bitVal_1 As Byte 
    Dim bitVal_2 As Byte 
    Dim bitVal_3 As Byte 
    Dim bitVal_4 As Byte 
    Dim bitVal_5 As Byte 
    Dim bitVal_6 As Byte 
    Dim bitVal_7 As Byte 
     
    'For the status port, the lower 3 bits are not used.... 
    'bitVal_0 = vbInp(StatusAddress) And BitMask_0 
    'bitVal_1 = vbInp(StatusAddress) And BitMask_1 
    'bitVal_2 = vbInp(StatusAddress) And BitMask_2 
    bitVal_3 = vbInp(StatusAddress) And BitMask_3 
    bitVal_4 = vbInp(StatusAddress) And BitMask_4 
    bitVal_5 = vbInp(StatusAddress) And BitMask_5 
    bitVal_6 = vbInp(StatusAddress) And BitMask_6 
    bitVal_7 = vbInp(StatusAddress) And BitMask_7 
     
    'StatusBit_0 = IIf(bitVal_0 > 0, True, False) 
    'StatusBit_1 = IIf(bitVal_1 > 0, True, False) 
    'StatusBit_2 = IIf(bitVal_2 > 0, True, False) 
    StatusBit_3 = IIf(bitVal_3 > 0, True, False) 
    StatusBit_4 = IIf(bitVal_4 > 0, True, False) 
    StatusBit_5 = IIf(bitVal_5 > 0, True, False) 
    StatusBit_6 = IIf(bitVal_6 > 0, True, False) 
    StatusBit_7 = IIf(bitVal_7 > 0, True, False) 
     
End Sub

en dan moet je ook nog ff het win95io.dll pakketje downloaden.. er is een site op internet die dit maakt... (kweet zo ff niet de link, zit op het werk, kijk strax thuis wel ff)


PS ook op www.aaroncake.net was er nog het een en ander te vinden...

hier dus :)

If it ain't broke, fix it till it is...

Pagina: 1