妳看看能不能滿足妳的要求:
Function?Dec2Hex_reversed(dec)If?IsNumeric(dec)?Then
rst=Hex(dec)'10進制轉換為16進制後的結果
raw_strlen=Len(rst)'rst實際的位數
If?(raw_strlen?Mod?2)=1?Then'轉換後的16進制數是奇數位,需要補零
output?=?output?&?0
output?=?output?&?Right(rst,1)?&?"?"'加上空格,看得更清楚
strlen=raw_strlen-1
Else
strlen=raw_strlen
End?If
For?i=strlen?To?2?Step?-2
output?=?output?&?Mid(rst,i-1,2)?&?"?"'加上空格,看得更清楚
Next
Dec2Hex_reversed=output?
Else
Dec2Hex_reversed="請輸入有效數字"
End?If
End?Function
input=InputBox("請輸入要轉換的數字")
WScript.Echo(Dec2Hex_reversed(input))