write a vb script to calculate factorial of a number?

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

i wrote vbscripit code in notepad i got error i am in learning stage if u ps tell me what wrong in my code my error is "object required descriptive at line one run time error"and my code is "set usernameobj=Descriptive.Create() usernameobj( "name").value="Username" set passwordobj=Descriptive.Create() passwordobj("name").value="password" set signinobj=Descriptive.Create() signinobj("name").value="sigin" browser("gmail").page("gmail").WebEdit("usernameobj").set ("enter username") Browser("gmail").Page("gmail").WebEdit("passwordobj").Set secure.Crypt.Encrypt("enter password") browser("gmail").page("gmail").WebButton("siginobj").click

1421


How are arrays declared in the vbscript language?

549


hi Set myobj=Description.Create() myobj("type").value="submit" myobj("name").value="google search" myobj("html tag").value="button" browser("title:=google").page("title:=google").webButton (myobj).Click i was running above code in one weak back it was working fine i got result,again i opened after few days ,again i was trying to run the code it shows run time error in last line of my code ,why ?pls answer my question?

1742


Mention what is the difference between vbscript and vba?

526


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

526






Give me sm ideas to write Vbscripts abt protocol testing abilash700@gmail.com.

1593


Capture the Unique label changes on google home page for I am feeling lucky button and save those label changes to Notepad Note: Using QTP

1877


How can you create an object in vbscript?

616


Mention what is the technology used by vb script?

523


When to use function procedures and what are its characteristics?

555


Which operator is used to perform the comparison among 2 operands in the vbscript language?

532


Which in-built function related to an array joins substrings into one string in the vbscript language?

520


Set srchobj=Description.Create() srchobj("type").value="text" srchobj("name").value="q" srchobj("html tag").value="input" browser("micclass:=google").Page("micclass:=google").webedit (srchobj).Set "qtp" what's wrong in my code pls tell me ? the above code working fine and i got my result pass,now i am trying to run the program it shows general run time error why?pls help me i am in learning stage ?

1554


What are the environments supported by vbscript language?

508


Explain vbscript in detail?

618