inf_9
inf_9
Library Functions
Library Functions: Library functions are those In-build functions that are already available in VB.
• STRING FUNCTIONS
• NUMERIC FUNCTIONS
• DATE & TIME FUCTIONS
• STRING FUNCTIONS String functions are used to work with strings in numerous ways such as
changing their cases, extracting some characters from a string, determining whether a character is part
of string etc.
Lcase ( ) : This function converts a given string into all lower case.
Syntax : Lcase(string)
Example : Print Lcase(“SCHOOL”)
Output : school
Ucase ( ) : This function converts a given string into all lower case.
Syntax : Ucase(string)
Example : Print Ucase(“school”)
Output : SCHOOL
> Len ( ) : This function gives the length of the string i.e. how many characters long the string
is. All characters are counted including spaces and punctuation.
Syntax : Len(string)
Example : Len(“kendriya vidyalaya”)
Output : 18
> Trim, LTrim and RTrim : LTrim ( ): This function removes leading spaces from a string.
Syntax : LTrim(string)
Example : LTrim(“ kendriya”)
Output : kendriya
Trim ( ) : This function removes all leading as well as trailing spaces from a string.
Syntax : Trim(string)
Example : Trim(“ kendriya ”)
Output : kendriya
Left ( ) : This function is used to extract a certain number of characters from the
leftmost portion of string.
Syntax : Left(string,no-of chars)
Example : Left(“vidyalaya”,5)
Output : vidya
Right ( ) : This function is used to extract a certain number of characters from the
rightmost portion of string.
> Mid ( ) : Mid function is used to extract Character from the middle of the given string,
SYNTAX : MID ( STRING, START_POSITION, NO_OF_CHAR )
EG: – Dim S as String
S = “Study Material for Bright Students”
PRINT MID(A,20,6) ‘ Will print Bright.
> Mid statement not only extracts the character but also replaces them with the text we specify.
> Instr ( ) : Instr function searches for strings within string. This function also needs
three arguments.
Output : ok bye
> String ( ) : This function is used for producing a string with a certain number of
repeating characters.
> ASC ( ) : This function is used to get a character’s equivalent ASCII code.
Syntax : ASC(string)
Example :
Dim a, b As String
a = "India"
b = Asc(a)
Print b
Output : 73
> Chr ( ) : This function returns a string containing the character associated with the
specified character code.
Syntax : chr(charcode)
Example :
Dim a As String
a = Chr(65)
Print a
Output : A
> StrReverse ( ) : This function returns a string in which the character order of a specified
string is reversed .
Syntax : StrReverse(string)
Example :
Dim a, b As String
a = "abc"
b = StrReverse(a)
Print b
Output : cba
NUMERIC FUNCTIONS VB supports many Numeric functions that can make your
complicated work very easy.
> Int ( ) and Fix ( ) :- This function simply truncates the fractional part .
Syntax :- Int(Number)
Example :- Int ()
Output :- 14
Syntax: :- Fix(Number)
Example :- Fix (-14)
Output :- -14
DATE and TIME FUNCTIONS : This section deals with various date and time functions.
Syntax : Now ( )
> Date ( ) : This function returns the current date in Variant type in following format
Syntax : Date ( )
Output : 16/6/08
> Date$( ) : This function returns the current date in String type in following format.
Syntax : Date$ ( )
Output : 01-23-2009
***