NUMERIC FUNCTIONS IN VISUAL BASIC
1. Round():
Description:
rounds the given number to the specified decimal places.
Syntax:
round(expression[,Numberofdecimalplaces])
Example:
round(3.7)=4
round(3.76,1)=3.8
round(3.786,2)=3.79
round(3.784,2)=3.78
2. sgn():
Description:
returns the sign of the given number
-1----->for negative number
1------>for positive number
0------>for zero
syntax:
sgn(number)
Example:
sgn(-23)=-1
sgn(23)=1
sgn(0)=0
[Link]():
Description:
Returns the absolute value of the given number.(removes the minus sign)
syntax:
abs(number)
example:
abs(-23)=23
abs(23)=23
4. sqr():
Description:
returns the square root of the given number.
Syntax:
sqr(number)
Example:
sqr(36)=6
[Link]():
Description:
returns the e to the power of x ,where e is the base for natural logarithms.
Syntax:
Exp(number)
Example:
Exp(4)=54.598
[Link]():
Description:
returns the natural logarithm of the given number.
Syntax:
log(number)
Example:
log(5)=1.609
[Link]():
Description:
returns the cosine value
Syntax:
cos(number)
Example:
cos(20)=0.4080
[Link]():
Description:
returns the sine of the number
Syntax:
sin(number)
Example:
sin(30)=0.8509
[Link]():
Description:
returns the tangent value of the given angle in radians.
Syntax:
tan(number)
Example:
tan(23)=1.5881
[Link]():
Description:
returns the integer part of a number
Syntax:
fix(number)
Example:
fix(4.0)=4
fix(4.5)=4
fix(4.567)=4
[Link]():
Description:
gives the greatest integer
Syntax:
int(number)
Example:
int(4.01)=4
int(4.5)=4
int(4.56)=4
[Link]():
Description:
calls the random number generator
syntax:
rnd()
Example:
rnd()=0.07556
DATE FUNCTIONS IN VISUAL BASIC
[Link]():
Description:
Returns the current date from the system clock
Syntax:
Date()
Example:
Date()=7/5/2016
[Link]():
Description:
Returns the day of the given string or number represents.
Syntax:
day(date)
Example:
day("5/6/2016")=6
day(now)=5
[Link]()
Description:
returns the hour of given string or number represents
Syntax:
hour(time)
Example:
hour(now)=12
[Link]():
Description:
returns the minute of given string or number represents.
Syntax:
minute(time)
Example:
minute(now)=33
[Link]():
Description:
returns the month of given string or number represents
Syntax:
month(date)
Example:
month("6/5/2016")=6
month(now)=7
[Link]():
Description:
returns the current time and date
Syntax:
now()
Example:
now()=7/6/2016 [Link] AM
7. Second():
Description:
returns the second of the given string or number represents
Syntax:
second(time)
Example:
second(now)=34
second("[Link]")=51
[Link]():
Description:
returns the current time in the system clock
Syntax:
time()
Example:
time()=[Link] PM
[Link]():
Description:
returns the day of the week a date corresponds to
Syntax:
Weekday(date)
Example:
weekday(now)=4
weekday("7/4/2016")=2
[Link]():
Description:
returns the year of the date corresponds to
Syntax:
year(date)
Example:
year(now)=2016
year("07/07/2015")=2015
[Link]:
Description:
returns the date of the given string or number represents
Syntax:
Datevalue(date)
Example:
datevalue(now)=7/6/2016
FINANCIAL FUNCTIONS IN VISUAL BASIC
[Link]():
Description:
returns the payment for an annuity based on periodic,constant payments and constant
interest rate.
Syntax:
pmt(rate,nper,wysw,wyew,wdyp)
rate-rate of interest
nper-number of periods
wysw-what you start with
wyew-what you end with
wdyp-when do you pay
Example:
Pmt(0.8 / 12, 30 * 12, 100000, 0, 1)=6250.00050672
[Link]():
Description:
future value of an annuity based on periodic payments and a constant interest rate.
Syntax:
FV(rate,nper,pmt[,pv[,type]])
rate-rate of interest
nper-no of periods
pmt-paymentperperiod
pv-start amount
type-when due
[Link]():
Description:
gives the interest paid over a given period of an annuity based on periodic,equal payments
and a constant interest rate.
Syntax:
IPmt(rate,per,nper,pv,fv,due)
rate-rate of interest
per-period in the range(1 through nper)
nper-no of periods
Example:
IPmt(.08/12,25,360,100000,0,1)
4. NPer():
Description:
tells how long it will take to accumulate an annuity.
Syntax:
NPer(rate,pmt,pv,fv,due)
Example:
NPer(.05/12,-1000,100000,0,1)
[Link]():
Description:
tells how much periodic payments made over the future
Syntax:
PV(rate,nper,pmt,fv,due)
rate-rate of interest
nper-total number of payments made
pmt-no of payments made for each period
fv-future value or cash balance you want after you have received the final payment.
Example:
PV(.06/12,120,-1000,0,1)
STRING FUNCTIONS IN VISUAL BASIC
[Link]-TO FIND THE LENGTH OF THE GIVEN STRING.
SYNTAX
:variable=len(string) VARIABLE SHOULD BE NUMERIC VARIABLE TO COLLECT THE
RESULT
EXAMPLE:
S=len("COMPUTER") OUTPUT WILL BE 8
[Link]-Returns a substring containing a specified number of characters from a string.
SYNTAX:
Mid(string, start[, length])
string Required. String expression from which characters are returned.
start Required; Long. Character position in string at which the part to be taken begins.
If start is greater than the number of characters in string, Mid returns a zero-length string
("").
length Optional; Long. Number of characters to return.
If omitted or if there are fewer than length characters in the text (including the character
at start), all characters from the start position to the end of the string are returned.
EXAMPLE:
strSubstr = Mid("Visual Basic", 3, 4) OUTPUT WILL BE strSubstr = "sual"
[Link]-Returns a substring containing a specified number of characters from the
beginning (left side) of a string.
SYNTAX:
Left(string, length)
string Required. String expression from which the leftmost characters are returned.
length Required; Long. Numeric expression indicating how many characters to return.
If 0, a zero-length string ("") is returned.
If greater than or equal to the number of characters in string, the entire string is returned.
EXAMPLE:
strSubstr = Left("Visual Basic", 3) OUTPUT WILL BE strSubstr = "Vis"
[Link]-Returns a substring containing a specified number of characters from the end
(right side) of a string.
SYNTAX:
Right(string, length)
string Required. String expression from which the rightmost characters are returned.
length Required; Long. Numeric expression indicating how many characters to return.
If 0, a zero-length string ("") is returned. If greater than or equal to the number of
characters in string, the entire string is returned.
EXAMPLE:
strSubstr = Right("Visual Basic", 3) OUTPUT WILL BE strSubstr = "sic"
[Link]-Converts all lowercase letters in a string to uppercase. Any existing uppercase
letters and non-alpha characters remain unchanged.
SYNTAX:
UCase(string)
EXAMPLE:
strNew = UCase("Visual Basic") OUTPUT WILL BE strNew = "VISUAL BASIC"
[Link]-Converts all uppercase letters in a string to lowercase. Any existing lowercase
letters and non-alpha characters remain unchanged.
SYNTAX:
LCase(string)
EXAMPLE:
strNew = LCase("Visual Basic") OUTPUT WILL BE strNew = "visual basic"
[Link]-Returns a Long specifying the position of one string within another.
The search starts either at the first character position or at the position specified by the
start argument,
and proceeds forward toward the end of the string (stopping when either string2 is found
or when the end of the string1 is reached).
SYNTAX:
InStr([start,] string1, string2 [, compare])
start Optional. Numeric expression that sets the starting position for each search. If
omitted, search begins at the first character position. The start argument is required if
compare is specified.
string1 Required. String expression being searched.
string2 Required. String expression sought.
compare Optional; numeric.
A value of 0 (the default) specifies a binary (case-sensitive) search.
A value of 1 specifies a textual (case-insensitive) search.
EXAMPLE:
lngPos = Instr("Visual Basic", "a") OUTPUT WILL BE lngPos = 5
[Link]-Returns a Long specifying the position of one string within another.
The search starts either at the last character position or at the position specified by the
start argument, and proceeds backward toward the beginning of the string (stopping when
either string2 is found or when the beginning of the string1 is reached).
SYNTAX:
InStrRev(string1, string2[, start, [, compare]])
string1 Required. String expression being searched.
string2 Required. String expression sought.
start Optional. Numeric expression that sets the starting position for each search.
If omitted, search begins at the last character position.
compare Optional; numeric. A value of 0 (the default) specifies a binary (case-sensitive)
search.
A value of 1 specifies a textual (case-insensitive) search.
EXAMPLE:
lngPos = InstrRev("Visual Basic", "a") OUTPUT WILL BE lngPos = 4
[Link]-Returns a string containing a repeating character string of the length specified.
SYNTAX:
String(number, character)
number Required; Long. Length of the returned string.
character Required; Variant.
This argument can either be a number from 0 to 255 (representing the ASCII character
code* of the character to be repeated) or a string expression whose first character is used
to build the return string.
EXAMPLE:
strTest = String(5, "a") OUTPUT WILL BE strTest = "aaaaa"
[Link]-Returns a string containing the specified number of blank spaces.
SYNTAX:
Space(number)
Where number is the number of blank spaces desired.
EXAMPLE:
strTest = Space(5) OUTPUT WILL BE strTest = " "
[Link]-Returns a string in which a specified substring has been replaced with another
substring a specified number of times.
SYNTAX:
Replace(expression, find, replacewith[, start[, count[, compare]]])
expression Required. String expression containing substring to replace.
find Required. Substring being searched for.
replacewith Required. Replacement substring.
start Optional. Position within expression where substring search is to begin. If omitted, 1
is assumed.
count Optional. Number of substring substitutions to perform. If omitted, the default value
is –1, which means make all possible substitutions.
compare Optional. Numeric value indicating the kind of comparison to use when
evaluating substrings. (0 = case sensitive, 1 = case-insensitive)
EXAMPLE:
strNewDate = Replace("08/31/2001", "/", "-") OUTPUT WILL BE strNewDate = "08-31-2001"
12. StrReverse-Returns a string in which the character order of a specified string is
reversed.
SYNTAX:
StrReverse(string)
EXAMPLE:
strTest = StrReverse("Visual Basic") OUTPUT WILL BE strTest = "cisaBlausiV"
[Link]-Removes leading blank spaces from a string.
SYNTAX:
LTrim(string)
EXAMPLE:
strTest = LTrim(" Visual Basic ") OUTPUT WILL BE strTest ="Visual Basic "
[Link]-Removes trailing blank spaces from a string.
SYNTAX:
RTriM(string)
EXAMPLE:
strTest = RTrim("Visual Basic")OUTPUT WILL BE strTest = "Visual Basic"
[Link]-Removes both leading and trailing blank spaces from a string.
SYNTAX:
Trim(string)
EXAMPLE:
strTest = Trim(" Visual Basic ")OUTPUT WILL BE strTest = "Visual Basic"
[Link]-Returns an Integer representing the ASCII character code corresponding to the
first letter in a string.
SYNTAX:
Asc(string)
EXAMPLE:
intCode = Asc("*") OUTPUT WILL BE intCode = 42
[Link]-Returns a string containing the character associated with the specified character
code.
SYNTAX:
Chr(charcode)
Where charcode is a number from 0 to 255 that identifies the character.
EXAMPLE:
strChar = Chr(65) OUTPUT WILL BE strChar = "A"