[原创]十六进制字符串转换成十进制数
<TABLE width="98%" border=0><TR>
<TD class=bw><FONT>/*============================================================*/<BR>// 函数名: f_hex2dec<BR>//<BR>// 作用范围: public<BR>/*------------------------------------------------------------*/<BR>// 描述: 十六进制字符串转换成十进制数<BR>/*------------------------------------------------------------*/<BR>// 参数: <BR>//<BR>// [<I>value</I>] string as_hex<BR>// 被转换的十六进制字符串<BR>/*------------------------------------------------------------*/<BR>// 返回值: LONG十进制数 ,失败返回-1<BR>/*------------------------------------------------------------*/<BR>// 作者: Wangnet 日期: 2004-2-2<BR>/*============================================================*/<BR>Int i<BR>Longll_return<BR>Int li_numbit<BR>String ls_bit<BR>Int li_lenth <BR><BR>li_lenth = Len(as_hex)<BR>For i = 1 To li_lenth<BR> ls_bit = Upper(Mid(as_hex,i,1))<BR> Choose Case ls_bit<BR>Case <I>'</I>0<I>'</I> To <I>'</I>9<I>'</I><BR> li_numbit = Integer(ls_bit)<BR>Case <I>'</I>A<I>'</I> To <I>'</I>F<I>'</I><BR> li_numbit = Asc(ls_bit) -55<BR>Case Else<BR> Return -1<BR> End Choose<BR> ll_return = ll_return + li_numbit*16^(li_lenth -i)<BR>Next<BR><BR>Return ll_return<BR></FONT></TD></TR></TABLE>
页:
[1]