Name
Oct Function
Class
Microsoft.VisualBasic.Conversion
Syntax
Oct(number
)
-
number
(required; Numeric or string capable of conversion to a number) A valid numeric or string expression
Return Value
String
Description
Returns the octal value of a given number
Rules at a Glance
If
number
is not already a whole number, it is rounded to the nearest whole number before being evaluated.If
number
isNothing
, an error occurs.Oct returns up to 11 octal characters.
Programming Tips and Gotchas
You can also use literals in your code to represent octal numbers by
appending &O
to the relevant octal value. For
example, 100 decimal has the octal representation
&O144
. The following two statements assign an
octal value to a variable:
lngOctValue1 = &H200 ' Assigns 128 lngOctValue2 = "&O" & Len(dblNumber) ' Assigns 8
See Also
Get VB.NET Language in a Nutshell, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.