Siebel VB Language Reference > VB Language Reference >

Oct Function


This standard VB function converts a number to an octal (base 8) number.

Syntax

Oct[$](number)

Argument
Description

number

Any numeric expression

Returns

The octal representation of a number, as a string.

Usage

If the numeric expression has a data type of integer, the string contains up to six octal digits; otherwise, the expression is converted to a data type of long, and the string can contain up to 11 octal digits.

The dollar sign ($) in the function name is optional. If it is included, the return data type is string. Otherwise the function returns a variant of vartype 8 (string).

NOTE:  To represent an octal number directly, precede the octal value with &O. For example, &O10 equals decimal 8 in octal notation.

Example

This example prints the octal values for the numbers from 1 to 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

See Also

Hex Function

Siebel VB Language Reference