Strings

A string is a type of variable in vb like a integer but instead of saving the data as a number it saves it as text. i.e dim name as string Some times we need to convert sttrings in to other types of variables. Like in this case you have made a program to add to numbers when you input the number you wish to add from the key bord vb will read it as a string so there has to be a way to convert strings to integer. From String to Intger CInt(s) From Intger to String CStr(n) From String to real CDbl(s) From Real to string CStr(r) From String to datatime CDate(s) From datatime to string Cstr(d) There are ways in VB to manipulate strings The Right Function The Right function extracts the right portion of a phrase. The format is  ** Right (“Phrase”, n) ** Where n is the starting position from the right of the phase where the portion of the phrase is going to be extracted. For example, Right(“Visual Basic”, 4) = asic The Left Function The Left$ function extract the left portion of a phrase. The format is  ** Left(“Phrase”, n) ** Where n is the starting position from the left of the phase where the portion of the phrase is going to be extracted. For example, Left (“Visual Basic”, 4) = Visu The Rtrim Function The Rtrim function trims the empty spaces of the right portion of the phrase. The format is  ** Rtrim(“Phrase”) ** .For example, Rtrim (“Visual Basic ”, 4) = Visual basic The Trim function The Ttrim function trims the empty spaces on both side of the phrase. The format is  ** Trim(“Phrase”) ** .For example, Trim (“ Visual Basic ”) = Visual basic The **Mid** function extracts a substring from the original phrase or string. It takes the following format: ** Mid(phrase, position, n) ** Where position is the starting position of the phrase from which the extraction process will start and n is the number of characters to be extracted. For example, Mid(“Visual Basic”, 3, 6) = ual Bas The InStr function The **InStr** function looks for a phrase that is embedded within the original phrase and returns the starting position of the embedded phrase. The format is  ** Instr (n, original phase, embedded phrase) ** Where n is the position where the Instr function will begin to look for the embedded phrase. For example Instr(1, “Visual Basic”,” Basic”)=8 The Ucase and the Lcase functions The **Ucase** function converts all the characters of a string to capital letters. On the other hand, the **Lcase** function converts all the characters of a string to small letters. For example, Ucase(“Visual Basic”) =VISUAL BASiC Lcase(“Visual Basic”) =visual basic The Str and Val functions .