Oct, Oct$ (functions)

Syntax

Oct[$](number)

Description

Returns a String containing the octal equivalent of the specified number.

Comments

Oct$ returns a String, whereas Oct returns a String variant.

The returned string contains only the number of octal digits necessary to represent the number.

The number parameter is any numeric expression. If this parameter is Null, then Null is returned. Empty is treated as 0. The number parameter is rounded to the nearest whole number before converting to the octal equivalent.

Example

This example accepts a number and displays the decimal and octal 'equivalent until the input number is 0 or invalid.

Const crlf = Chr$(13) + Chr$(10)

Sub Main()
  Do
    xs$ = InputBox("Enter a number to convert:","Octal Convert")
    x = Val(xs$)
    If x <> 0 Then
      MsgBox "Decimal: " & x & " Octal: " & Oct(x)
    Else
      MsgBox "Goodbye."
    End If
  Loop While x <> 0
End Sub

See Also

Hex, Hex$ (functions).

More information

O