Get Octal Method
The Get Octal method converts a number to an octal (base 8) number. It returns the octal representation of a number as a string. The following data type of the integer determines the octal digits that the string can contain:
Is an integer data type. The string can contain up to six octal digits.
Is not an integer data type. This method converts the expression to a long data type. The string can contain up to 11 octal digits.
To represent an octal number, you precede the octal value with the following code:
&O
For example, the following code equals decimal 8 in octal notation:
&O10
Format
Oct[$](number)
For information about the dollar sign, see Usage of the Dollar Sign.
This method uses the same arguments as the Get Absolute Value method. For more information, see Get Absolute Value Method.
Example
The following example prints the octal values for the numbers 1 through 15:
Sub Button_Click
Dim x As Integer, y As Integer
Dim msgtext As String
Dim nofspaces As Integer
msgtext = "Octal numbers from 1 to 15:" & Chr(10)
For x = 1 to 15
nofspaces = 10
y = Oct(x)
If Len(x) = 2 then
nofspaces = nofspaces - 2
End If
msgtext = msgtext & Chr(10) & x & Space(nofspaces) & y
Next x
End Sub