📄 module1.bas
字号:
Attribute VB_Name = "Module1"
Public Declare Function DlPortReadPortUchar Lib "dlportio.dll" (ByVal Port As Long) As Byte
Public Declare Function DlPortReadPortUshort Lib "dlportio.dll" (ByVal Port As Long) As Integer
Public Declare Function DlPortReadPortUlong Lib "dlportio.dll" (ByVal Port As Long) As Long
Public Declare Sub DlPortReadPortBufferUchar Lib "dlportio.dll" (ByVal Port As Long, Buffer As Any, ByVal Count As Long)
Public Declare Sub DlPortReadPortBufferUshort Lib "dlportio.dll" (ByVal Port As Long, Buffer As Any, ByVal Count As Long)
Public Declare Sub DlPortReadPortBufferUlong Lib "dlportio.dll" (ByVal Port As Long, Buffer As Any, ByVal Count As Long)
Public Declare Sub DlPortWritePortUchar Lib "dlportio.dll" (ByVal Port As Long, ByVal Value As Byte)
Public Declare Sub DlPortWritePortUshort Lib "dlportio.dll" (ByVal Port As Long, ByVal Value As Integer)
Public Declare Sub DlPortWritePortUlong Lib "dlportio.dll" (ByVal Port As Long, ByVal Value As Long)
Public Declare Sub DlPortWritePortBufferUchar Lib "dlportio.dll" (ByVal Port As Long, Buffer As Any, ByVal Count As Long)
Public Declare Sub DlPortWritePortBufferUshort Lib "dlportio.dll" (ByVal Port As Long, Buffer As Any, ByVal Count As Long)
Public Declare Sub DlPortWritePortBufferUlong Lib "dlportio.dll" (ByVal Port As Long, Buffer As Any, ByVal Count As Long)
Function BinToDec%(BinNumber$)
Dim Weight%
Dim Dec%
Dim i%
Weight% = 1
Dec% = 0 'Reset decimal number
If BinNumber$ <> "00000000" Then
For i% = Len(BinNumber$) To 1 Step -1
If Mid$(BinNumber$, i%, 1) = "1" Then
Dec% = Dec% + Weight% 'If bit=1 then add weigth factor
End If
Weight% = Weight% * 2 'Multiply weight factor by 2
Next
BinToDec% = Dec% 'Store result
Else
BinToDec% = 0
End If
End Function
Function DecToBin$(Decnumber%)
'Conversion of decimal number (0...255) to 8 bit binary string.
'--------------------------------------------------------------
Dim Bin$
Dim Faktor%, i%
Bin$ = ""
Faktor% = 128
If Decnumber% <> 0 Then
For i% = 1 To 8
If Faktor% > Decnumber% Then
Bin$ = Bin$ + "0"
Else
Bin$ = Bin$ + "1"
Decnumber% = Decnumber% - Faktor%
End If
Faktor% = Faktor% \ 2
Next
DecToBin$ = Bin$
Else
DecToBin$ = "00000000"
End If
End Function
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -