|
本帖最后由 online041 于 2010-4-15 17:52 编辑
这是源代码
Dim $Unit=0,$Ten=0 ,$Hundred=0,$Thousand=0
Dim $Digit=1
Dim $Num,$NewNum
$Num=InputBox("数值","输入不大于4位数")
If @error=1 Or $Num="" Then
Exit
EndIf
Select
Case $Num>=0 And $Num<10
$Digit=1
$Unit=Mod($Num,10)
$NewNum=$Unit
Case $Num>=10 And $Num<100
$Digit=2
$Unit=Mod($Num,10)
$Ten=Mod(($Num-$Unit)/10,10)
$NewNum=$Unit*10+$Ten
Case $Num>=100 And $Num<1000
$Digit=3
$Unit=Mod($Num,10)
$Ten=Mod(($Num-$Unit)/10,10)
$Hundred=Mod(($NewNum-$Ten*10-$Unit)/100,10)
$NewNum=$Unit*100+$Ten*10+$Hundred
Case $Num>=1000 And $Num<10000
$Digit=4
$Unit=Mod($Num,10)
$Ten=Mod(($Num-$Unit)/10,10)
$Hundred=Mod(($NewNum-$Ten*10-$Unit)/100,10)
$Thousand=Mod(($Num-$Hundred*100-$Unit)/1000,10)
$NewNum=$Unit*1000+$Hundred*10+$Thousand
EndSelect
MsgBox(0,"数字","这是一个"&$Digit&"位数"&@CRLF _
&"个位"&$Unit&@CRLF&"十位"&$Ten&@CRLF&"百位"&$Hundred&@CRLF _
&"千位"&$Thousand&@CRLF&"重组新数"&$Num)
我想知道这三条要怎么理解
$Ten=Mod(($Num-$Unit)/10,10)
$Hundred=Mod(($NewNum-$Ten*10-$Unit)/100,10)
$Thousand=Mod(($Num-$Hundred*100-$Unit)/1000,10) |
|