Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - Character variables are converted to integers.
Character variables are converted to integers.
Try the following example:

1. Use cast

Dim a is a string and I is an integer.

a=" 12.53 "

i=a

Now the string a is converted into the integer i.

2. Use the type conversion function Cint ()

Dim a is a string and I is an integer.

a=" 12.53 "

i=Cint(a)

3. Use the Val () function

This function returns a number contained in a string, which is an appropriate type of numeric value.

Dim a is a string and I is an integer.

a=" 12.53 "

i=Val(a)

Note: "i=Val(a)" here actually uses the function of data type coercion mentioned above. If the previous definition is changed to "I is single-precision", the value output to I is the single-precision floating-point data of 12.53 instead of the integer of 13.