ChrNum

=Characters and Numbers=

Run BASIC has several functions that manage conversions between numeric and string values, or handle characters of text. The syntax for these functions is as follows:

ASC(a$) //- ASCII value of first character of string a$// CHR$(x) //- String containing character of ASCII value x// DECHEX$(x) //- Hexadecimal string for decimal value of x// HEXDEC(h$) //- Decimal number from hexadecimal string// SPACE$(i) //- A string containing i space characters// STR$(x) //- String representation of number x// USING(f$, x) //- Formatted string of x using f$ as a template.// VAL(a$) //- a$ converted to a numeric value//


 * USING$(f$, x) - Formatted string of v using f$ as a template. - documentation error. Do not use the dollar sign. The correct format is listed above.**

Some further information:


 * Using** requires a template string made with the character **#**. The template may contain a decimal point. It may not contain other characters, such as a dollar sign. It is useful for lining up columns of numbers. Note that it performs a rounding operation. The number 741.345 is rounded to 741.35 when the template calls for only two places to the right of the decimal point. This is demonstrated in the code below.


 * Val** returns a numeric value for the string expression if the string expression represents a valid numeric value or if it begins with a valid numeric value. If not, then zero is returned.

Here is some sample code that demonstrates the use of these functions.

code format="vbnet" print asc("X") print chr$(169) print dechex$(255) print hexdec("FF") print "10 spaces:";space$(10);"." print str$(467) print using("####.##",741.345) print val("27") code

The output from this program looks like this: code 88 © FF 255 10 spaces:. 467 741.35 27 code