ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

VBA 左移和右移

2021-05-13 09:05:48  阅读:332  来源: 互联网

标签:右移 VBA End rs Cells 左移 LShift sc modelid


'左移函数

Function LShift(Value, Shift)

    Set sc = CreateObject("MSScriptControl.ScriptControl")

    sc.Language = "JScript"

    LShift = sc.Eval(Value & "<<" & Shift)

End Function

 

'右移函数

 

Function RShift(Value, Shift)

    Set sc = CreateObject("MSScriptControl.ScriptControl")

    sc.Language = "JScript"

    RShift = sc.Eval(Value & ">>" & Shift)

End Function

 

工作中遇到的加密算法示例:

Sub MyModelID()

 

    Dim i As Integer

    Dim rs  As Long

    Dim n_brandid  As Long

    Dim n_modelid  As Long

   

    For i = 2 To UsedRange.Rows.Count

        rs = Cells(i, 2) Mod LShift(1, 7) 'Brandid

        n_brandid = rs + LShift(rs, 7)

        n_modelid = Cells(i, 1) Xor n_brandid

        n_modelid = LShift(n_modelid, 7) + rs

        Cells(i, 6) = n_modelid

       

        If IsNumeric(Cells(i, 3)) And IsEmpty(Cells(i, 3)) <> True Then

            Cells(i, 8) = Cells(i, 3) * 2 / 60 + 2

            Cells(i, 9) = Cells(i, 4) / 60

            Cells(i, 10) = Cells(i, 5) / 60

        Else

            Cells(i, 8) = 8888

            Cells(i, 9) = 8888

            Cells(i, 10) = 8888

        End If

           

       

       ' Debug.Print Cells(i, 6)

    Next

   

    MsgBox "完成!"

   

End Sub

 

标签:右移,VBA,End,rs,Cells,左移,LShift,sc,modelid
来源: https://www.cnblogs.com/april6/p/14763004.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有