what is diff b/n these 2 programs
1) for i=5 to 1 step 2
msgbox "pass"
next
2_) for i=5 to 1 step -2
msgbox "pass"
next

Answers were Sorted based on User's Feedback



what is diff b/n these 2 programs 1) for i=5 to 1 step 2 msgbox "pass" next 2_) for i..

Answer / veer

From the first one will not display any message box because the condition is not true but it shows result as "done" in the result window .

From the second one will display a message box "pass" 3 times

Is This Answer Correct ?    8 Yes 0 No

what is diff b/n these 2 programs 1) for i=5 to 1 step 2 msgbox "pass" next 2_) for i..

Answer / mano

the above answer is right but in second program pass wil display 3 times

Is This Answer Correct ?    6 Yes 0 No

what is diff b/n these 2 programs 1) for i=5 to 1 step 2 msgbox "pass" next 2_) for i..

Answer / manisha

In the first one it will not display any result.Because the
condition given is wrong .

In the second one the result is displayed as pass for 3
times.

Condition for ForLoop:-
the limit must be in increament order (OR) if the limit is
decreament order we have to mention "Step -n",where n is
to skip or jump .


In the above example:-
For the 1st - no result
for the 2nd - The result is displayed as pass for 3 times.
because for i=5 to 1 step -2
i=5
i=3(jumped to 5-2=3)
i=1(jumped to 3-2=1)

Is This Answer Correct ?    5 Yes 0 No

what is diff b/n these 2 programs 1) for i=5 to 1 step 2 msgbox "pass" next 2_) for i..

Answer / ankit

OH ya...i agree
it will show message 3 times

Is This Answer Correct ?    4 Yes 0 No

what is diff b/n these 2 programs 1) for i=5 to 1 step 2 msgbox "pass" next 2_) for i..

Answer / ankit

the first one will not print any message because the
condition is not true

the second one will print message pass 2 times

Is This Answer Correct ?    1 Yes 4 No

Post New Answer

More VB Script Interview Questions

write a program to display the system specifications of client system with the help of vb script.

1 Answers  


How to create a function in vbscript?

0 Answers  


Which conditional statement is the most convenient one to use in the case of multiple conditions in the vbscript language?

0 Answers  


write script to open Gmail.com, and to write script for entering username and password and show whether the result as pass or fail

2 Answers   Thomson Reuters,


Inorder to avoid Message box while writing script which alternative method can be used?

1 Answers  






Hi Friends, I have an issue like the describe below: I'm using QTP and I'm testing on SharePoint. As you knoe, SharePoint has a customize function for user, so that, If I add an object Web Table at the first time, that object was recognized by "index" and "html tag", after that, if someone change the display of web part, the "Index" of my object was changed as well and QTP unable to select that Web Table. Can you guide me how to identify or anyway to keep that Web Table object as unique object? Thanks a lot.

0 Answers   CSC,


How will you convert a string to lower case string using vbscript?

0 Answers  


How to Import data from a file (file is on the desktop) to the data table

2 Answers   IBM,


Which function allows you to instantiate an object given its programmatic identifier or progid?

0 Answers  


Difference between Function and Sub routine?

0 Answers   Polaris,


Mention if qtp generates vbscript code as we record actions, can't it possible to directly write using vbscript code when qtp does the same thing too?

0 Answers  


write a vb script to display the number is odd or even and whether it is divisible by 9 or not

2 Answers  


Categories