write a vb script to display first 5 odd numbers from 1 to 100

Answers were Sorted based on User's Feedback



write a vb script to display first 5 odd numbers from 1 to 100 ..

Answer / mudaseer

dim i,vcnt,vstro
vcnt=0
for i=1 to 100 step 2
vstro=vstro & i & vbnewline
vcnt=vcnt+1
if vcnt=5 then exit for
next
msgbox vstro

Is This Answer Correct ?    14 Yes 2 No

write a vb script to display first 5 odd numbers from 1 to 100 ..

Answer / eswar

cnt =0
For i=1 to 100
If (i mod 2 <> 0) Then
MsgBox i
cnt=cnt+1
End If
If cnt=5 Then
Exit for
End If

Next

Is This Answer Correct ?    7 Yes 3 No

write a vb script to display first 5 odd numbers from 1 to 100 ..

Answer / anjali tamrakar

Private sub form_load()
Dim a as integer
Dim b as integer
B=0
For A=1 to 100 step2
B=B+A
Print A,B
Next A
End sub

Is This Answer Correct ?    5 Yes 3 No

write a vb script to display first 5 odd numbers from 1 to 100 ..

Answer / psri

dim a(50)
j=0
for i = 1 to 100

if (i mod 2) <> 0 then
a(j)=i
j=j+1
cnt=cnt+1
End if
next
msgbox "The odd no is "& join(a) &"The total no of odd no's
is"&cnt

Is This Answer Correct ?    2 Yes 3 No

Post New Answer

More VB Script Interview Questions

What is the difference between function and procedure?

0 Answers  


Hi, Anybody could tell me What is the script for Reverse of Given number. Ex:236--632. Thanks in Advance..

10 Answers   Amazon, CSC,


How to get path of the file through scripting?

1 Answers   Hexaware,


where can i learn VB scripint ?

0 Answers   Satyam,


what is the differance between BYVAL,BYREF?

0 Answers  






Mention what is vbscript?

0 Answers  


this q asked in applabs, q is: QTP should open google.com page and enter "qtp" in one edit(search) box and click search and should open google.com again and enter "job" in edit(search) box and click on search. I tried this but getting error "Edit(search) box matches more than one object", could anyone this question plz..

1 Answers   AppLabs,


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

0 Answers  


Write a Program to add 2 numbers without using operators (+,-) and without using third variable. Note: Use VBScript only Hint: You can use other operators like '/' & '*'(Division & Multiplication)

0 Answers   Quest,


Difference between Do while loop and while wend loop

1 Answers  


HI how can handle dynamic image through vb script example we have to create email id fill the edit box(these latters change wrong password) i am wating your answer

1 Answers  


Write a Fucntion to close all Opened browser expect desired one?

2 Answers   Ness Technologies,


Categories