Result = Instr (Startpos, String 1, String 2)
Startpos : Start position in String 1 from where String 2
has to be searched.
String 1 : String in which String 2 has to be searched.
String 2 : String to be searched.
23. Isarray ()
Returns True if a variable is an array; otherwise, returns False.
Result = Isarray (Variable)
24. InputBox ()
Shows a dialogue box with a Text Box, an OK button, and a Cancel button. The
Input given by a user is returned as a string: InputBox (Prompt, Title, Default,
Xpos, Ypos
Prompt : The message to be displayed in the dialogue box. It can have a
maximum of 1024 characters and can be displayed in multi-lines
in the dialogue box by using
chr (13) or chr (10).
Title : The caption which is to be displayed in the title bar of the Text
Default : The default string that is displayed in the Text Box.
Xpos : Position of the Input Box from the left side of the screen.
Ypos : Position of the Input Box from the top of the screen. If the X and Y
position is not specified, the InputBox appears at the center of the
screen. Title, Default, Xpos, and Ypos are optional.
25. IsDate ()
Returns True if the argument is date type; otherwise, returns False.
IsDate (Variable name)
26. IsEmpty ()
Returns True if a variable is not initialized.
IsEmpty (Variable name)
27. IsNull ()
Returns True if the expression has no data; otherwise, returns False.
28. IsNumeric ()
Returns True if an expression is a valid number.
29. Ltrim ()
Returns a string with no leading spaces.
Result = Ltrim (“ World”) ‘Returns “World”
30. Rtrim ()
Returns a string with no trailing spaces.
Result = Rtrim (“World ”) ‘Returns ”World”
31. Trim ()
Returns a string without leading and trailing spaces.
Result = Trim (“ World ”) ‘Returns “World”
32. MsgBox ()
Displays a message box with command buttons and waits for a response from the
MsgBox (Prompt, Buttons, Title)
Prompt : The message to be displayed in the dialogue box. The message can
be a maximum of 1024 characters. The message can be displayed in
more than one line by using the chr(13) or chr(10) characters.
Button : The button that is displayed in the dialogue box. It may be the
OK Button, Cancel Button, Retry Button, Ignore Button, etc. If no
button is specified, the OK Button is displayed by default.
We can use any combination of the buttons or icons from the following list.
Syntax Description
VbOKOnly OK Button is displayed
VbOKCancel Two Buttons, OK and Cancel, are displayed
VbyesNO Yes and No Buttons are displayed
VbyesNoCancel Yes, No, and Cancel Buttons are displayed
VbRetryCancel Retry and Cancel Buttons are displayed
VbAbortRetryIgnore Abort, Retry, and Ignore Buttons are displayed
VbMsgBoxHelpButton Help Button is displayed
VbCritical Displays Critical message icon
VbExclamation Displays an icon with exclamation mark
VbQuestion Displays a question mark icon
VbInformation Displays an information icon
VbDefaultButton1 First Button is default
VbDefaultButton2 Second Button is default
VbDefaultButton3 Third Button is default
VbDefaultButton4 Fourth Button is default
VbSystemModal All applications are terminated until user responds
VbMsgBoxRight Displays Text with right alignment
Return Value of Command Buttons
Button Type Return Value
OK 1
Cancel 2
Abort 3
Retry 4
Ignore 5
Yes 6
No 7
You can use a combination of buttons and icons by using the ‘+’ character.
MsgBox (“Do you want to print”, VbYesNo + VbQuestion, “Print”)
33. Month ()
Returns the month from the given date.
Result = Month (date)
34. Now ()
Returns the current date and time.
Result = Now
35. Second ()
Returns the second from date.
Result = Second (date)
36. Sqr ()
Returns the square root of a number.
37. String ()
Returns a string of the given characters and length specified.
Result = String (10, “–”) ‘Returns “--------”
38. Str ()
Converts a number to a string.
Result = Str (123.10) ‘Returns “123.10”
39. Time ()
Returns current system time.
40. Val ()
Converts a string to a number.
Result = Val (“123”) ‘Returns “123”
Result = Val (“1234Hello”) ‘Returns “1234”
41. Weekday ()
Returns number of the weekday from a date.
Result = Weekday (date)
42. Year ()
Returns year from a date.
Result = year ( #1-Jan–2005#) ‘Returns “2005”

Get Software Engineering and Testing now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.