⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 read_m_bit.bas

📁 可以读些S7-300PLC中的变量数据
💻 BAS
字号:
Attribute VB_Name = "READ_M_BIT"
Public Function READ_IQM_BYTE_BIT(ByVal IQM_BYTE As Integer, IQM_BIT As Integer) As Integer
'------------------十进制转二进制------------------------------------------------
Dim HighBit As Long '转换成二进制的最高位数
Dim AndResult As Long  '相与后的结果

Dim BinaryString As String
Dim DecimalConvertBinary As String
Dim float_count(1024)
BinaryString = ""
HighBit = 65536
            While (HighBit > 0.5) '
                AndResult = HighBit And IQM_BYTE
                If (AndResult <> 0) Then
                    BinaryString = BinaryString + "1"
                    Else
                    BinaryString = BinaryString + "0"
                End If
                HighBit = HighBit / 2 '每次右移一位
            Wend
        DecimalConvertBinary = BinaryString '存储的是二进制数的字符串
'******************************************************************************************
Binary_String = Trim(DecimalConvertBinary)

BinaryStrLength = Len(Binary_String)

IQM_BYTE_BIT_RIGHT = Right(Binary_String, IQM_BIT + 1)

IQM_BYTE_BIT_RESULT = Left(IQM_BYTE_BIT_RIGHT, 1)

READ_IQM_BYTE_BIT = IQM_BYTE_BIT_RESULT

End Function

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -