VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



As well as Hex(), VB will convert decimal to octagonal, but not back again. Here's how... Also, for

by Craig Hillsdon (7 Submissions)
Category: Math/Dates
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Thu 24th August 2000
Date Added: Mon 8th February 2021
Rating: (1 Votes)

As well as Hex(), VB will convert decimal to octagonal, but not back again. Here's how... Also, forgot to mention last time, my Dec2Bin &

Rate As well as Hex(), VB will convert decimal to octagonal, but not back again. Here's how... Also, for




    multiplier = 1

    decout = 0
    octstr = "01234567"
    For i = Len(myoct) To 1 Step -1
        z = Mid(myoct, i, 1)
        v = Val(InStr(1, octstr, z)) - 1
        If v + 1 = 0 Then
            MsgBox "Invalid input", , "Error"
            decout = -1
            Exit Function
        End If
        decout = decout + v * multiplier
        multiplier = multiplier * 8
    Next i

End Function

Sub convertOct2Dec()

    Dim decout As Long
    Dim myoct As String
    
    myoct = InputBox("Octagonal")
    Octagonal2Decimal myoct, decout
    If decout <> -1 Then MsgBox decout
    
End Sub

Download this snippet    Add to My Saved Code

As well as Hex(), VB will convert decimal to octagonal, but not back again. Here's how... Also, for Comments

No comments have been posted about As well as Hex(), VB will convert decimal to octagonal, but not back again. Here's how... Also, for. Why not be the first to post a comment about As well as Hex(), VB will convert decimal to octagonal, but not back again. Here's how... Also, for.

Post your comment

Subject:
Message:
0/1000 characters