这里有一段实现word防拷贝的代码,可是其中少了一个自编函数和提取程序段,请各位高手帮忙补全,不胜感激!
Function hidebyte()
Dim j As Integer
Dim i As Integer
Dim ch(1 to N) As Byte'数组按字节放入待隐藏的秘密信息
Dim chbyte As Byte
'...........  '给ch(1)到ch(n)赋值的语句省略
Selection.MoveRight unit:=wdCharacter,count:=8,Extend:=wdExtend
with selection.font
.nameAscii="Basemic Times"
end with '连续8个字符为“Basemic Times”,为提取秘密字节设置的开始标志
selection.moveRight unit:=wdCharacter,count:=1
For j=1 to n '每次循环隐藏一字节
m=&H80
for i=1 to 8 '每次循环隐藏一比特二进制位
Selection.moveRight unit:=wdCharacter,count:=1,Extend:=wdExtend
With selection.font  '根据比特位的1或0改变英文字体
  chbyte=ch(j) and m
if chbyte=m then
.nameAscii="Times New Roman"
Else
.nameAscii="Basemic Times"
end if
m=shiftRight(m,1) ‘shiftRight()为自编右移位函数
end with
selection.moveleft unit:=wdCharacter,count:=1
selection.moveright unit:=wdCharacter,count:=1
next i
next j
end function

解决方案 »

  1.   

    http://dev.firnow.com/course/7_databases/access/ac_m/2007614/51282.html刚学VBA,网上找到许多资料,才发现,其实如果提问的方式是很难解决问题的。自己Google上面搜,选择适合的关键字,这样反而能够解决问题。顺便贴上自己在写的代码:Public Function SHR(OPR As Byte, n As Integer) As Byte '自编移位函数
        Dim BD As Byte
        Dim I As Integer
        BD = OPR
        For I = 1 To n - 1
            BD = BD \ 2 '右移
        Next I
        CF = BD And 1 '判断D0位是否进位
        SHR = BD \ 2
        
    End Function这是移位函数。调用的时候:
    Sub text()
        m = &H80
        m = SHR((m), 1)  '调用的时候还是要这样在括号里面加括号
        
        MsgBox m
    End Sub测试可以 哈哈