标题: [原创]闲来无事编了一个十六进制乘法表供大家学习
[打印本页]
作者: beeny
时间: 2008-4-7 11:34
标题: [原创]闲来无事编了一个十六进制乘法表供大家学习
来DOS联盟有些时日在这里学了不少东西!
再次谢谢中国DOS联盟
dim i,j,str,s
for i = 1 to 15
for j=1 to i
s=h16(i,j)
str=str & s & " "
next
str=str & vbcrlf
next
set fso=createobject("scripting.filesystemobject")
set f1=fso.createtextfile("1.txt")
f1.write str
f1.close
set fso=nothing
wscript.echo "ok"
'十六进制乘法口决表
function h16(a,b)
dim s1,s2,s3
if a<10 then
s1=a
else
s1=sh(a)
end if
if b<10 then
s2=b
else
s2=sh(b)
end if
if a*b<10 then
s3=a*b
else
s3=sh(a*b)
end if
h16=s1 & "*" & s2 & "=" & s3
end function
'十进制转十六进
function sh(num)
dim i,j,s4
i=num
do while i>0
j=i mod 16
select case j
case 0,1,2,3,4,5,6,7,8,9
s4=j & s4
case 10
s4="A" & s4
case 11
s4="B" & s4
case 12
s4="C" & s4
case 13
s4="D" & s4
case 14
s4="E" & s4
case 15
s4="F" & s4
end select
i=i\16
loop
sh=s4
end function