write a vb script to calculate factorial of a number?

Answers were Sorted based on User's Feedback



write a vb script to calculate factorial of a number?..

Answer / mudaseer

vf=1
vnum=inputbox("enter a no")
for i=2 to vnum
vf=vf*i
next
msgbox vf

Is This Answer Correct ?    98 Yes 25 No

write a vb script to calculate factorial of a number?..

Answer / raja

Dim n,f
n=inputbox("enter a number")
f=1
If n<0 Then
msgbox "invalid number"
else if n=0 or n=1 then
msgbox "the factorial of given number is : "& f
else
For i=1 to n
f=f*i
Next
msgbox "the factorial of given number is : "&f
End If
end if

Is This Answer Correct ?    77 Yes 19 No

write a vb script to calculate factorial of a number?..

Answer / rik mondal

The answer submitted by "mudaseer" is absolutely wrong and
the answer by "raja" is partially correct(because he did not
wrote additional HTML and script tags,which is difficult to
understand for beginners). Guys don't you check the answer
before posting?
anyways here is the correct answer. This will work 100%.
Just copy it and paste in you editor then save and compile
by IE.


<html>
<script language="vbscript">
n=inputbox("Enter a number")
dim f
f=1
if n<0 then
Msgbox "Invalid number"
elseif n=0 or n=1 then
MsgBox "The factorial of given number "&n&" is :"&f
else
for i=n to 2 step -1
f=f*i
next
MsgBox "The factorial of given number "&n&" is :"&f
end if
</script>
</html>

Is This Answer Correct ?    41 Yes 16 No

write a vb script to calculate factorial of a number?..

Answer / arvind singh

a = InputBox("Enter a no to calculate factorial for")
Result = 1
Do While a > 0
Result = Result*(a)
a = a-1
Loop
MsgBox Result

Is This Answer Correct ?    8 Yes 4 No

write a vb script to calculate factorial of a number?..

Answer / mogal

n = 12345
f =1
for i =1 to len(n)
f = f* i
next
msgbox f

Is This Answer Correct ?    1 Yes 2 No

Post New Answer

More VB Script Interview Questions

why do u choose to go for testing why cant for devoloping

0 Answers  


How to open a file. What is the perpose of true and false mode there?

0 Answers  


Give examples where vb script can directly run on users system with windows as os?

1 Answers  


What is variant in vb script?

0 Answers  


In html file what is an ideal position to include 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,


which one is more secure vb script or java script ??????? or both are same ??????

3 Answers  


Is vbscript a case-sensitive or case-insensitive?

0 Answers  


Write a program to print all lines that contains a word either “testing” or “qtp”

2 Answers  


how to write vb script code for login gmail page by using notepad and how to run script in notepad

1 Answers  


Why do we use Option Explicit?

6 Answers  


Hi this is Vinoth. I need a help on below mentioned question A combobox contains list of items assume as 5 I have to get each items Individually and I have to Export to datatable. Please help me on this. Thanks

0 Answers  


Categories