Tuesday, April 27, 2010

String Handling



Remember strings? They are the data type that holds letters, spaces, words and text. In QBasoc we used



  1. LEN(mystring) to find the length of a string

  2. LEFT$(mystring, x) to find the first x characters of a string

  3. RIGHT$(mystring, x) to find the last x characters of a string

  4. MID$(mystring, y, x) to find x characters of a string starting at position y

A common technique used with strings is to use a FOR loop to cycle through the letters in the string:

FOR i = 1 to LEN(mystring)

PRINT MID$(mystring, i, 1)

NEXT i

What are the equivalent techniques for these functions in Visual Basic? See Program Example 14 String Handling 1.

No comments: