VBS tutorial: Functions – cbyte functions

Time:2021-9-5

Cbyte function

Returns an expression that has been converted toByteSubtypeVariant

CByte(expression)

expressionArgument is any valid expression.

explain

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.