1 個解答
- 匿名使用者1 0 年前最佳解答
就把兩個八進位的數值轉成十進位
再作家法
最後把得到的數值轉成八進味即可
2009-12-20 13:17:15 補充:
設VB2005程式碼
在Textbox1輸入被加數
textbox2輸入加數
2009-12-20 13:17:26 補充:
Public Function cd(Dnum As Long, add As Byte) As String
Dim u As Long, s As String, n
n = Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z")
u = Dnum
s = n(u Mod w)
2009-12-20 13:17:35 補充:
While u >= w
u = u \ w
s = n(u Mod w) & s
Wend
cd = s
End Function
2009-12-20 13:17:43 補充:
Public Function dc(Cnum As String, w As Byte) As Long
Dim s As String, v As Long, l As Long, i As Long
For i = 1 To Len(Cnum)
s = Mid(Cnum, i, 1)
If s >= "A" Then
v = Asc(s) - 55
Else
v = CLng(s)
End If
l = l + v * w ^ (Len(Cnum) - i)
Next
dc = l
End Function
2009-12-20 13:17:46 補充:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
dim a,b,c as long
a=dc(Textbox1.text,8)
b=dc(Textbox2.text,8)
c=a+b
Msgbox(cd(c,88))
End sub
2009-12-20 13:19:13 補充:
Msgbox(cd(c,88))改為Msgbox(cd(c,8))
參考資料: Sally的淺見