write a vb script to calculate factorial of a number?
Answers were Sorted based on User's Feedback
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 |
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 |
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 |
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 |
Which operator can be used to check if two numbers are equal or not in vbscript?
after medical test,when will be the police verification
how to comvert 120 into one hunderd twenty rupees only and vice varsa
Explain few date functions in vbscript?
Mention what is the main difference between function and sub-procedure?
Write a program using Java Script / VBscipt that checks if two matrices have identical values in all the elements
we executed QTP scripts in one browser(i.e IN)same scripts is working on another browsers or not (i.e mean netscap,m azol..like )
What are class properties?
Why to add checkpoint in QTP What's the purpose of checkpoints & how to add it
Hi everybady, i have faced few Qns in one of i attended interview, please help me out with these below Qns. 1. how to join values without using join function? 2. how to compare values without using String compare function? 3. input is Bangalore, but i need output like this below format, what is function to use and get this outcome B A N G A L o R E 4. Input is "CapGemini" but uotput should be like this "inimeGpaC" 5. Input is 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5 Can someone let me know results of this Qns, please. Thanks.
I have an excel sheet with multiple ID's in a column. Now i need fetch those ID's in an application and check whether if it already exist in the DB. If not then i have to go with the process of inserting them in the DB. If it exists then i need to skip that ID and move to the next ID and check the same and proceed. How can i do that with for loop and if condition?
how to automatically update the sql server2005 database records when insert in vb6?