鸿业设备设计暖通空调:vb中把十进制转换成十六进制日的代码

来源:百度文库 编辑:神马品牌网 时间:2024/05/03 03:15:03

在VB中:a=Hex(b),a为结果,b为要转换的数。

给你一个我写的C#的函数,你自己修改一下吧
//十进制转化十六进制
public string DecToHex(long dec)
{
dec = System.Math.Abs(dec);
string RelVal=string.Empty,tempStr=string.Empty;
const int Q = 16;
long temp;
char[] HexStr ={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G'};
///
///
///
while(dec !=0)
{
temp=dec % Q;
dec = Convert.ToInt64(dec / Q);
RelVal = HexStr[temp].ToString() + RelVal;
}
return RelVal;
}