View contents of this chapter

The ASCII Functions

The Chr() and Asc() functions can be used to convert strings to and from their numeric ASCII values.The ASCII table lists every possible character available on the PC and assigns a sequential number (ASCII code) to each character.

Chr(charcode)
Asc(string)

The Chr() function returns a String containing the character associated with the specified character code. The Asc() returns an Integer representing the character code corresponding to the first letter in a string. Consider the following statements:

str1 = Chr(65)  'stores an A in str1
int1 = Asc("A")  'stores 65 in int1

The Substring Functions

The substring functions return parts of strings. The following table lists these functions:

Function name Description
Right() Returns a Variant (String) containing a specified number of characters from the right side of a string.
Left() Returns a Variant (String) containing a specified number of characters from the left side of a string.
Mid() Returns a Variant (String) containing a specified number of characters from a string.

Consider the following statements:

str1 = "abcdef"
strPart1 = Left(str1, 2)     'stores ab
strPart2 = Right(str1, 2)    'stores ef
strPart3 = Mid(str1, 2, 3)   'stores cde

 



© Universal Teacher Publications        INDEX Previous Screen Next Screen