用asp的for...next语言做简单16转10进制 “12345”

编程~~
2025-12-16 20:36:52
推荐回答(2个)
回答1:

<%
nums="a100"
chn10(nums)

Function chn10(nums)
Dim tmp,tmpstr,i

nums_len=Len(nums)
For i=1 To nums_len
tmp=Mid(nums,i,1)
If IsNumeric(tmp) Then
tmp=tmp * 16 * (16^(nums_len-i-1))
Else
tmp=(ASC(UCase(tmp))-55) * (16^(nums_len-i))
End If
tmpstr=tmpstr+tmp
Next
Response.Write tmpstr
End Function
%>

回答2:

for i=1 to 16

if i=10 then
i=a
elseif i=11 then
i=b
elseif i=12 then
i=c
elseif i=13 then
i=d
elseif i=14 then
i=e
elseif i=15 then
i=f
else
i=i
end if

next