没有合适的资源?快使用搜索试试~ 我知道了~
VB 位操作函数
3星 · 超过75%的资源 需积分: 50 15 下载量 79 浏览量
2018-03-24
15:54:26
上传
评论
收藏 8KB TXT 举报
温馨提示
试读
11页
VB位操作相关函数,方便直接调用,比较实用。。。。。
资源推荐
资源详情
资源评论
'功能: 将字节变量循环左移n位
'入口参数:MoveByte 需要移位的字节变量
' n 移动的位数
'返回值: 移位后的字节变量
Public Function ByteLeftMove(MoveByte As Byte, N As Integer) As Byte
Dim Intem As Byte '临时变量
Dim Intem1 As Byte '临时变量
Dim x As Integer, y As Integer
Intem1 = MoveByte
For x = 1 To N '移多少位就循环多少次
For y = 8 To 1 Step -1 '从第八位(左边第一位)开始循环左移
Select Case y
Case 8
'如果临时变量intem1的第八位是1,
If (Intem1 And &H80) = &H80 Then
'则将临时变量intem置1,
Intem = &H1
Else
Intem = &H0 '反之置0
End If
Case 7
'如果临时变量intem1的第七位是1,
If (Intem1 And &H40) = &H40 Then
'则将其第八位置1(其它位不变),
Intem1 = Intem1 Or &H80
Else
'反之将第八位置0(其它位不变)
Intem1 = Intem1 And &H7F
'入口参数:MoveByte 需要移位的字节变量
' n 移动的位数
'返回值: 移位后的字节变量
Public Function ByteLeftMove(MoveByte As Byte, N As Integer) As Byte
Dim Intem As Byte '临时变量
Dim Intem1 As Byte '临时变量
Dim x As Integer, y As Integer
Intem1 = MoveByte
For x = 1 To N '移多少位就循环多少次
For y = 8 To 1 Step -1 '从第八位(左边第一位)开始循环左移
Select Case y
Case 8
'如果临时变量intem1的第八位是1,
If (Intem1 And &H80) = &H80 Then
'则将临时变量intem置1,
Intem = &H1
Else
Intem = &H0 '反之置0
End If
Case 7
'如果临时变量intem1的第七位是1,
If (Intem1 And &H40) = &H40 Then
'则将其第八位置1(其它位不变),
Intem1 = Intem1 Or &H80
Else
'反之将第八位置0(其它位不变)
Intem1 = Intem1 And &H7F
End If
Case 6
'操作与上面相同
If (Intem1 And &H20) = &H20 Then
Intem1 = Intem1 Or &H40
Else
Intem1 = Intem1 And &HBF
End If
Case 5
If (Intem1 And &H10) = &H10 Then
Intem1 = Intem1 Or &H20
Else
Intem1 = Intem1 And &HDF
End If
Case 4
If (Intem1 And &H8) = &H8 Then
Intem1 = Intem1 Or &H10
Else
Intem1 = Intem1 And &HEF
End If
Case 3
If (Intem1 And &H4) = &H4 Then
Intem1 = Intem1 Or &H8
Else
Intem1 = Intem1 And &HF7
End If
Case 2
If (Intem1 And &H2) = &H2 Then
Intem1 = Intem1 Or &H4
Else
Case 6
'操作与上面相同
If (Intem1 And &H20) = &H20 Then
Intem1 = Intem1 Or &H40
Else
Intem1 = Intem1 And &HBF
End If
Case 5
If (Intem1 And &H10) = &H10 Then
Intem1 = Intem1 Or &H20
Else
Intem1 = Intem1 And &HDF
End If
Case 4
If (Intem1 And &H8) = &H8 Then
Intem1 = Intem1 Or &H10
Else
Intem1 = Intem1 And &HEF
End If
Case 3
If (Intem1 And &H4) = &H4 Then
Intem1 = Intem1 Or &H8
Else
Intem1 = Intem1 And &HF7
End If
Case 2
If (Intem1 And &H2) = &H2 Then
Intem1 = Intem1 Or &H4
Else
剩余10页未读,继续阅读
资源评论
- qxhuan2019-01-02刚下载,准备尝试,希望好用
chenzp531
- 粉丝: 7
- 资源: 7
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功