📄 devaddr.bas
字号:
Attribute VB_Name = "DEVADDR"
'Option Explicit
Function device_address$(a$)
b0$ = Left$(a$, 1)
alen% = Len(a$)
b1$ = Right$(a$, alen% - 1)
contact_no% = CInt(b1$)
'
Select Case b0$
Case "X"
If contact_no% > 177 Then b1$ = "0000"
ch_base% = 4 * 16 * 16 'base address 0400hex
If contact_no% >= 100 Then ch_base% = (4 * 16 - 1) * 16 'base address 0440hex
address$ = device_XY_addr$(b1$, ch_base%)
'
Case "Y"
If contact_no% > 177 Then b1$ = "0000"
ch_base% = 5 * 16 * 16 'base address 0500hex
If contact_no% >= 100 Then ch_base% = (5 * 16 - 1) * 16 'base address 0540hex
address$ = device_XY_addr$(b1$, ch_base%)
'
Case "T"
If contact_no% > 255 Then b1$ = "0000"
ch_base% = 6 * 16 * 16 'base address 0600hex
address$ = device_TCMS_addr$(b1$, ch_base%)
'
Case "C"
If contact_no% > 255 Then b1$ = "0000"
ch_base% = 14 * 16 * 16 'base address 0E00hex
address$ = device_TCMS_addr$(b1$, ch_base%)
'
Case "M"
Select Case contact_no%
Case 0 To 1023: ch_base% = 8 * 16 * 16
Case 8000 To 8255
ch_base% = 15 * 16 * 16
b1$ = CStr(CInt(b1$) - 8000)
Case Else: b1$ = "0000"
End Select
address$ = device_TCMS_addr$(b1$, ch_base%)
'
Case "S"
If contact_no% > 999 Then b1$ = "0000"
ch_base% = 0 * 16 'base address 0000hex
address$ = device_TCMS_addr$(b1$, ch_base%)
End Select
address$ = "0000" + address$
address$ = Right(address$, 4)
' exchange order
high_byte$ = Mid$(address$, 1, 2)
low_byte$ = Mid$(address$, 3, 2)
device_address$ = low_byte$ + high_byte$
End Function
Function device_XY_addr$(b1$, ch_base%)
'
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -