Documente Academic
Documente Profesional
Documente Cultură
ANDHRA PRADESH
Name : K. Sreeramacharyulu
Designation : Lecturer
Branch : Commercial and Computer Practice
Institute : Govt. Polytechnic, Srikakulam
Year/Semester : V Semester
Subject : VISUAL BASIC-I
Sub. Code : CCP-503
Topic : Programming Fundamentals
Duration : 50 Minutes
Sub. Topic : Built in Functions in VB
Teaching Aids : PPT, Clips and Images
CCP503.38 1
Objectives
CCP503.38 2
Recap
CCP503.38 3
Library or Built-in Functions
CCP503.38 4
Some of Built-In functions:
String functions
Int : Takes a numeral and returns an integer value
Syntax: Int (expression)
Example: length =Int( Totallength / 2),
Int(12.45)=12
CCP503.38 5
InStr : Returns the first position of a string inside
another string . If string not found , returns 0
Syntax :
Instr ([ start position], string , substring [,compare])
Example :
Debug. Print instr(6, “I study 3rd DCCP”, “6th Sem “)
CCP503.38 6
Left : Returns desired number of characters from
the left hand side of string
Syntax: Left ( String , Length)
Example : SAlphabets = “ABCDEFGH”
spiece = Left ( SAlphabets , 3)
Debug. print spiece
Output would be : ABC
CCP503.38 7
Right : Returns desired number of characters from
the right hand side of string
Syntax: Right ( Sstring , Length)
Example : SAlphabets = “ABCDEFGH”
spiece = Right ( SAlphabets , 3)
Debug. print spiece
Output would be : FGH
CCP503.38 8
Mid : Returns characters from any part of a string
Syntax : Mid (String , start ,[ , and length]))
Example : SAlphabets = “ABCDEFGH”
spiece = Mid ( SAlphabets ,4, 3)
Debug. print spiece
Output would be : DEF
CCP503.38 9
Lcase : Returns a string with all letters converted to
lower
Syntax : Lcase (String)
CCP503.38 10
TRIM : Trim function returns a copy of a string
without leading spaces (Ltrim) , without trailing
spaces(RTrim) , or without both leading and trailing
spaces (Trim)
Syntax : Ltrim (String)
Rtrim (String)
Trim (string)
CCP503.38 11
Asc : Returns the ASCII character code
corresponding to first letter in a string
Syntax : Asc (String)
ASC(“A”) – returns 65
Chr : Returns character associated with specified
character code
Syntax : Chr (Char code)
Chr (65) –returns “A”
Space : Returns a string consisting of specified
number of spaces
Syntax : Space (number)
Space (10) – returns 10 spaces
CCP503.38 12
String : Returns a repeating character string of the
length specified
Syntax : String (number , character)
Example : Dim sString as string * 20
sString = String (20,” * ”)
Debug.Print sString
Output: shows 20 stars
CCP503.38 13
Date and Time functions
Now : Returns current System date & time
Example : Dim DtToday As Date
DtToday = Now
Debug . Print DtToday – shows current
CCP503.38 15
TimeValue : Takes a string representation of time
and converts it to a date data type
Example : Dim dtMyDate as Date
Dim sMystring as string
sMystring = “08:30:00”
dtMyDAte = Timevalue(sMystring)
CCP503.38 17
Frequently Asked Questions
2. What is a Built-in function and give an example?
CCP503.38 18
Quiz
1 Len() is ____
A. Procedure
B. Function
C. Built-in function
D. User defined Function
CCP503.38 19
Assignment
1. Explain any 10 built-in functions
CCP503.38 20