Tuesday, August 10, 2010

Visual Basic String Function : Format

Purpose : The Format function take a string , number , or date variant and returns a formatted number , date or time.

Syntax :
Format ( expression , "format1; format2" , firstdayofweek , firstweekofyear )

expression : specifies the data to format
format1,2, ..... : Specifies how to format expression .Multiple formats are separated by semicolons. This argument is optional.
firstdayofweek : Used when formatting dates. This arguments is optional
firstweekofyear : Used when formatting dates. This arguments is optional

Formats Available

(0) : Displays a zero or a number.
(#) : Displays a number or nothing
( . ) : Displays a decimal point. the actual decimal point is based on the regional settings

SFormat = " Currency "
Picture1.Print SFormat & " : " ; Tab(30) ; Format ( Val ( Text1) , SFormat )
SFormat = " ######.00 "
Picture1.Print SFormat & " : " ; Tab(30) ; Format ( Val ( Text1) , SFormat )
SFormat = " 000000.## "
Picture1.Print SFormat & " : " ; Tab(30) ; Format ( Val ( Text1) , SFormat )
SFormat = " Standard "
Picture1.Print SFormat & " : " ; Tab(30) ; Format ( Val ( Text1) , SFormat )
SFormat = " General Number "
Picture1.Print SFormat & " : " ; Tab(30) ; Format ( Val ( Text1) , SFormat )
SFormat = " Fixed "
Picture1.Print SFormat & " : " ; Tab(30) ; Format ( Val ( Text1) , SFormat )
SFormat = " Percent "
Picture1.Print SFormat & " : " ; Tab(30) ; Format ( Val ( Text1) , SFormat )
SFormat = " Scientific "
Picture1.Print SFormat & " : " ; Tab(30) ; Format ( Val ( Text1) , SFormat )

No comments:

Post a Comment