Oct, Oct$ Functions
See Also Example
Returns text that represents the octal value of the decimal argument.
Oct returns a Variant; Oct$ returns a String.
The argument number can be any numeric expression It is rounded to the nearest whole number before being evaluated. An error occurs if number is a Variant of VarType 1 (Null )..
If the argument is an Integer or a Variant of VarType 2 (Integer) or VarType 0 (Empty), up to six octal characters are returned; if the argument is any other numeric data type or a Variant of any other type, up to 11 octal characters are returned.
You can represent octal numbers directly by preceding numbers in the proper range with &O. For example, &O10 is the octal notation for decimal 8.
Hex, Hex$ Function
Oct, Oct$ Function Example
The example uses Oct to return the octal representation of a decimal number. To try this example, paste the code into the Declarations section of a form. Then press F5 and click the form.
Sub Form_Click ()
Dim Msg, Num ' Declare variables.
Num = InputBox("Enter a number.") ' Get user input.
Msg = Num & " decimal is &O"
Msg = Msg & Oct(Num) & " in octal notation."
MsgBox Msg ' Display results.