VBS tutorial: Functions – cbyte functions


Cbyte function

Returns an expression that has been converted toByteSubtypeVariant


expressionArgument is any valid expression.


In general, you can write code using subtype conversion functions to show that the results of some operations should be represented as a specific data type rather than the default type. For example, in the case of currency, single precision, double precision, or integer operations, useCByteForce byte operation.

CByteThe function is used to transfer data from other data types toByteSubtypes are converted to internationally recognized formats. For example, the identification of decimal separators, such as the thousand separator, may depend on the locale of the system.

IfexpressionAn error occurs when the byte subtype is outside the acceptable range. The following example usesCByteThe function converts expression to byte:

Dim mydouble, mybytemydouble = 125.5678 'mydouble is a double value. Mybyte = cbyte (mydouble) 'mybyte contains 126.