Professional Documents
Culture Documents
Unit II - Built in Functions
Unit II - Built in Functions
1)Now Function:
It Returns both date and time stored in computer's
clock.
Syntax: Now()
Example : Print Now()
Output is 07/12/2017 11:14:58 PM
2) Date Function
Returns the system date.
Syntax: Date()
Example :
Print Date() ---- > Output is 07/12/2017
3) Time Function
Returns System time.
Syntax: Time()
Example:
Example :
Print Day(Now) Output is 11
Print Month(Now) Output is 7
Print Year(Now) Output is 2017
6) Hour, Minute and Second Functions
Returns hour, minute, and seconds in numeric form
Syntax:
Hour(DateArgument)
Minute(DateArgument)
Second(DateArgument)
Example:
Syntax:
Timer()
Example:
Print Timer() Output is 84878.33
i.e, this much seconds have passed since midnight.
current time is 11:35 PM with some seconds.
Formatting Functions
The three most common formatting functions in VB
are Tab, Space, and Format
1)The Tab function
Syntax : Tab (n); x
• The item x will be displayed at a position that is n
spaces from the left border of the output form.
• There must be a semicolon in between Tab and the
items you intend to display.
Example
Private Sub Form_Load
Print "I"; Tab(5); "like"; Tab(10); "to"; Tab(15); "learn"; Tab(20);"VB"
Print
Print Tab(10); "I"; Tab(15); "like"; Tab(20); "to"; Tab(25); "learn"; Tab(20); "VB"
Print
Print Tab(15); "I"; Tab(20); "like"; Tab(25); "to"; Tab(30);"learn"; Tab(35); "VB"
End sub
2) The Space function
The Space function is very closely linked to the Tab
function. However, there is a minor difference. While
Tab (n) means the item is placed n spaces from the
left border of the screen, the Space function specifies
the number of spaces between two consecutive
items.
Example
Private Sub Form_Activate()
Print "Visual"; Space(10);"Basic"
End Sub