Дополнительная инфа в файле !comexe.nfo в кодировке dos cyillic.
Код
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)
Function BitRead%(Variable%, BitNumber%)
'Returns the value (0 or 1) of the requested bit in a Variable .
Dim BitValue%
'the value of the requested bit
BitValue = 2 ^ BitNumber
BitRead = (Variable And BitValue) \ BitValue
End Function
Sub BitReset(Variable%, BitNumber%)
'Resets (clears) the requested bit in
Dim BitValue, CurrentValue%
'the value of the requested bit
BitValue = 2 ^ BitNumber
Variable = Variable And (&HFFFF - BitValue)
End Sub
Sub BitSet(Variable%, BitNumber%)
'Sets the requested bit in a Variable .
Dim BitValue, CurrentValue%
'the value of the requested bit
BitValue = 2 ^ BitNumber
Variable = Variable Or BitValue
End Sub
Sub BitToggle(Variable%, BitNumber%)
'Toggles the requested bit in a Variable.
Dim BitValue, CurrentValue%
'the value of the requested bit
BitValue = 2 ^ BitNumber
'Is the current value 0 or 1?
CurrentValue = Variable And BitValue
Select Case CurrentValue
Case 0
'If current value = 0, set it
Variable = Variable Or BitValue
Case Else
'If current value - 1, reset it
Variable = Variable And (&HFFFF - BitValue)
End Select
End Sub
Function ControlPortRead%(BaseAddress%)
'Reads a parallel port's Control port .
'Calculates the Control-port address from the port's
'base address, and inverts bits 0, 1, & 3 of the byte
'The Control-port hardware reinverts these bits,
'so the value read matches the value at the connector .
ControlPortRead = (Inp(&H37A) Xor &HB)
End Function
Sub ControlPortWrite(BaseAddress%, ByteToWrite%)
'Writes a byte to a parallel port's Control port .
'Calculates the Control-port address from the port's
'base address, and inverts bits 0, 1, & 3 .
'The Control-port hardware reinverts these bits,
'so Byte is written to the port connector .
Out &H37A, ByteToWrite Xor &HB
End Sub
Function DataPortRead%(BaseAddress%)
'Reads a parallel port's Data port .
DataPortRead = Inp(&H378)
End Function
Sub DataPortWrite(BaseAddress%, ByteToWrite%)
'Writes a byte to a parallel port's Data port .
Out &H378, ByteToWrite
End Sub
Function StatusPortRead%(BaseAddress%)
'Reads a parallel port's Status port .
'Calculates the Status-port address from the Port's
'base address, and inverts bit 7 of the byte
'The Status-port hardware reinverts these bits,
'so the value read matches the value at the connector .
StatusPortRead = (Inp(&H379) Xor &H80)
End Function
Public Function DecToBin(ByVal DeciValue As Long, Optional ByVal NoOfBits As Integer = 8) As String
Dim i As Integer
Do While DeciValue > (2 ^ NoOfBits) - 1
NoOfBits = NoOfBits + 8
Loop
DecToBin = vbNullString
For i = 0 To (NoOfBits - 1)
DecToBin = CStr((DeciValue And 2 ^ i) / 2 ^ i) & DecToBin
Next i
End Function
Function AsciiBin(ByVal Symbol As String) As String
DeciValue = Asc(Symbol)
AsciiBin = DecToBin(DeciValue)
End Function
Язык Visual Basic 6.0 является устаревшим. Многие примеры, размещенные на нашем сайте, были созданы еще во времена Windows 98 и могут не работать в современных операционных системах.
Если у вас возникнут какие-либо проблемы или вопросы, вы можете обратиться за помощью на наш форум.
Добавлять комментарии могут только зарегистрированные пользователи сайта.
Если у Вас уже есть учетная запись на Kbyte.Ru, пройдите процедуру авторизации.
Если Вы еще не зарегистрированы на Kbyte.Ru - зарегистрируйтесь.