Truncate Strings

 

The "Left$()" function shortens a string from the left by a specified number of characters. The "Right$()" function shortens a string from the right and the "Mid$()" function cuts out part of the string.

The second parameter specifies the maximum number of places in the result.

 

Examples:

Left$ ("combit", 1)                 Result: "c"

Mid$("combit",1,2)                  Result: "om"

Right$("combit",3)                  Result: "bit"

 

The "StrPos()" and "StrRPos()" functions return the position of the nth occurrence of a search string in a string. You can supply a third parameter specifying which occurrence of the search string is to be returned. The first character of the string corresponds to position 0. This means that with this function, you can extract a substring from the string, e.g. from the first space onwards.

 

Example:

Left$ ("John Smith",StrPos("John Smith"," "))  Result: "John"

 

 

The "Rtrim$()" function removes spaces at the end of a string, the "Atrim$()" function removes them from the beginning and the end of a string.

 

Example:

RTrim$ ("Hello World      ")       Result: "Hello World"