CByte Function

Tips >>ASP Functions


WANTS TO MAKE SOFTWARE WITHOUT KNOWLEDGE OF ASP? CLICK HERE

The CByte function converts an expression to type Byte. Its parameter is expression which describes a valid expression. In general, you can document your code using the subtype conversion functions to show that the result of some operation should be expressed as a particular data type rather than the default data type. For example, use CByte to force byte arithmetic in cases where currency, single-precision, double-precision, or integer arithmetic normally would occur. Use the CByte function to provide internationally aware conversions from any other data type to a Byte subtype. For example, different decimal separators are properly recognized depending on the locale setting of your system, as are different thousand separators. If expression lies outside the acceptable range for the byte subtype, an error occurs.


The Syntax of CByte function is :-

CByte(expression)

Example#1 :-

Code :-
dim a
a=134.345
document.write(CByte(a))
Output :-

134

Example#2 :-

Code :-
dim a
a=14.345455
document.write(CByte(a))
Output :-
14

Example#3 :-

Code :-
Dim MyDouble, MyByte
MyDouble = 125.5678 ' MyDouble is a Double.
MyByte = CByte(MyDouble) '
MyByte contains 126.
Output :-

Hence,CByte contains 126

Example#4 :-

Before:Code:After:
0CByte("0")0
255CByte("255")255
256CByte("256")error

 

 
E-mail : sales@virtualsplat.com
Phone : +91-9892413501

Whatsapp Icon +91-9967648641

Whatsapp Icon +91-9967648641