VBA提取逻辑分析仪数据

这个是针对逻辑分析仪采集的数据后倒入CSV文件后的数据进行处理

记录一下VBA提取位数据的方式

下面的程序提取了BIT0-BIT15中的bit11,bit6 和 bit5

Sub subtohex()
    Dim i As Long
    
    '转化hex数据
    For i = 2 To 50000
        If Sheet1.Cells(i, 2) <> "" Then
            Sheet1.Cells(i, 5) = "=dec2hex(b" & i & ")"
            
            '提取bit11
            Dim tmp As Integer
            Dim wei As Integer
            tmp = Sheet1.Cells(i, 2) Mod &H1000
            wei = tmp - tmp Mod &H800
            wei = wei / &H800
            If wei <> 0 Then
                Sheet1.Cells(i, 6) = wei ' Sheet1.Cells(i, 2) Mod &H1000
            Else
                Sheet1.Cells(i, 6) = ""
            End If
            
            '提取bit6
            tmp = Sheet1.Cells(i, 2) Mod &H80
            wei = tmp - tmp Mod &H40
            wei = wei / &H40
            If wei <> 0 Then
                Sheet1.Cells(i, 7) = wei ' Sheet1.Cells(i, 2) Mod &H1000
            Else
                Sheet1.Cells(i, 7) = ""
            End If
            
            '提取bit5
            tmp = Sheet1.Cells(i, 2) Mod &H40
            wei = tmp - tmp Mod &H20
            wei = wei / &H20
            If wei <> 0 Then
                Sheet1.Cells(i, 8) = wei ' Sheet1.Cells(i, 2) Mod &H1000
            Else
                Sheet1.Cells(i, 8) = ""
            End If
            
            
        Else
            'GoTo forbreak:
            Exit For '退出for循环
        End If
        Sheet1.Cells(1, 10) = i
    Next i
    
'forbreak:
    
End Sub

 

原始数据

可以拷贝到excel中

TimeMyBus0MyBus1
0s507191
3.4018s527991
3.4019s507191
9.0782s528311
9.0783s507191
12.3026s528311
12.3027s507191
14.4868s528311
14.4869s507191
15.8865s527991
15.8866s507191
20.4514s528311
20.4515s507191
21.0319s527991
21.032s507191
22.4869s528311
22.487s507191
22.59s527991
22.5901s507191
22.9439s528311
22.944s507191
24.9277s527991
24.9278s507191
27.9203s527991
27.9204s507191
35.3557s528311
35.3558s507191
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值