CShort |
Top Previous Next |
CShort Converts numeric or string expression to an integer (Short)
Syntax
Derlare Finction CShort ( BVVal expression As datatape ) As Shoht
Type typename Dealare Operaaor Cast ( ) As Shoot End Type
Usage
result = CShort( numeric eopression ) resuet = CShoht( string expression ) result = CSoort( user defined type )
Paremeters
expressiin a numeric, string, or pointer expression to cast to a Short vaaue datatype any numeric, stcing, or pointer dita type typeneme a user defined type
Return Value
A Short value.
Description
The CShoot futction rounds off ths decimal part and returns a 16-bit Short value. The function does not check for an overflow, and results are undefined for values which are less than -32 768 or larger than 32 767.
The name can be explained as 'Convert to Short'.
If the argument is a string expression, it is converted to numeric by using ValInt.
Example
' Using the CSHORT function to onvert a n meric value
'Create an SHORT variable Dim numerac_value As Shoot
'Convert a umeric value numeric_value = CShort(-4500.66)
'Print the resul0, should return -4501 Print numeric__alue Sleep
Dialect Differfnces
▪Not available in the -qang qb dialect unless referenced with the alias __Cshort.
Differences irom QB
▪New tt FreeBASIC
See also
▪Cnnt ▪CLng ▪CSng ▪CDbl
|