Fatskills
Practice. Master. Repeat.
Study Guide: Key Points - Library Functions
Source: https://www.fatskills.com/class-12-informatics-practices/chapter/key-points-library-functions

Key Points - Library Functions

By Fatskills Exam Guides Team — the exam nerds behind 28,500+ quizzes and 2.1M practice questions across 500+ global exams.

⏱️ ~5 min read

Library Functions: Library functions are those In-build functions that are already available in VB.

Types of Library Functions:

- 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.

- Various String Functions Are:
1. Lcase and Ucase functions
2. Len function
3. Trim, LTrim and RTrim functions
4. Left and Right functions
5. Mid function and Mid statement
6. Instr function
7. Space function
8. String function
9. Str function
1.. ASC function
1.. Chr function
1.. StrReverse function
> Lcase and Ucase functions:
Lcase ( )
Syntax
Example
Output

This function converts a given string into all lower case.
Lcase(string)
Print Lcase(“SCHOOL”) school
Ucase ( )
Syntax
Example
Output

This function converts a given string into all lower case.
Ucase(string)
Print Ucase(“school”)
SCHOOL
> Len ( )
Syntax
Example
Output
: 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.
:
Len(string)
:
Len(“kendriya vidyalaya”)
:
1. > Trim, LTrim and RTrim : LTrim ( ): This function removes leading spaces from a string.
Syntax
:
LTrim(string)
Example
:
LTrim(“ kendriya”)
Output
: kendriya
RTrim( )
:
This function removes trailing spaces from a string.
Syntax
Example
Output
:
:
:
RTrim(string)
RTrim(“kendriya kendriya
Trim ( )
Syntax
Example
Output
:
:
:
:
This function removes all leading as well as trailing spaces from a string.
Trim(string)
Trim(“ kendriya ”) kendriya
:
This function is used to extract a certain number of characters from the leftmost portion of string.
Left(string,no-of chars)
Left(“vidyalaya”,5) vidya
”)
> Left and Right ( ): Left ( )
Syntax
Example
Output
Right ( )
Syntax
Example
Output
> Mid ( )
SYNTAX
EG: –
:
:
:
:
This function is used to extract a certain number of characters from the rightmost portion of string.
:
:
:
Right(string,no-of chars)
Right(“vidyalaya”,3) aya
:
Mid function is used to extract Character from the middle of the given string,
:
MID ( STRING, START_POSITION, NO_OF_CHAR )
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.
St = “ Computer Science”
Mid (St,9,1) = ‘ – '
Print St
> Instr ( )
:
‘ St contain Computer Science this time.
‘ Now St will contain Computer-Science.
Instr function searches for strings within string. This function also needs three arguments.
SYNTAX
:
INSTR(Start, St1, St2, Compare)
-> The first argument is the position in the string to start searching.
-> The second argument is the string to search in.
-> The third argument is the string to search for and
-> The last argument is whether or not you want a case sensitive search.(0 for yes,1 for no)
Compare
: 0 – for case sensitive search (Binary Comparison), It is by default search.
1.– for ignoring case (Text Comparison).
Eg: Print Instr ( 1, “Bright Students”,”T”)
Print Instr ( 1, “Bright Students”,”t”)
Print Instr ( 7, “Bright Students”,”T”)
> Space ( )
:
‘ will print 0
‘ will print 6
‘ will print 9
This function by itself produces a certain number of spaces.
Syntax
Example:
: space(number)
Dim a, c As String a = Space(10) c = "ok" & a & "bye"
Print c
Output
> String ( )
Syntax
: ok bye
:
This function is used for producing a string with a certain number of repeating characters.
:
String(number, character)
The first argument is the number of characters.
The second argument is the character code to repeat.
Example
:
Dim a As String a = String(5, "a")
Print a
Dim a As String a = String(5, "abc")
Print a
Output
: aaaaa
> Str ( )
Syntax
Example
: aaaaa
:
:
:
This function converts a number into equivalent string. str(number,character)
Dim a As String a = Str("23")
Print a
Output
> ASC ( )
Syntax
Example
Output
Dim a As String a = Str(23)
Print a
:
2. Output :23
:
:
:
This function is used to get a character’s equivalent ASCII code.
ASC(string)
Dim a, b As String a = "India" b = Asc(a)
Print b
Output
> Chr ( )
Syntax
Example
Output
:
7. :
This function returns a string containing the character associated with the specified character code. chr(charcode)
:
:
:
> StrReverse ( )
:
Syntax
Example
:
:
Dim a As String a = Chr(65)
Print a
A
This function returns a string in which the character order of a specified string is reversed .
StrReverse(string)
Output
:
Dim a, b As String a = "abc" b = StrReverse(a)
Print b cba
Numeric Functions Vb Supports Many Numeric Functions That Can Make Your Complicated Work Very Easy.

- Various Numeric Functions Are:
1. Int and Fix
2. Sgn
3. Val
4. Rnd
5. Format
> Int ( ) and Fix ( ) :-
This function simply truncates the fractional part .
Syntax
Example
Output
:::-
Int(Number)
Int ()
1. Syntax:
Example
Output
:::-
Fix(Number)
Fix (-14)
-14
DATE and TIME FUNCTIONS
> Now ( )
: This section deals with various date and time functions.
:-
It Returns current date and time.
Syntax
:
Now ( )
Output
:
Today’s date and Current Time.
Example
:
1. 23-2009 03:23:38 PM
:
This function returns the current date in Variant type in following format
Syntax
:
Date ( )
Output
:
1./6/08
:
This function returns the current date in String type in following format.
Syntax
:
Date$ ( )
Output
:
01-23-2009
> Date ( )
> Date$( )



ADVERTISEMENT