Write VB script to test given number is Prime Number
Answer Posted / rvanamala
'--------- "n" is a given number
n = 101
retval= PrimeNo(n)
If strComp(retVal,"1",1) =0 Then
MsgBox n &" is a Prime Number"
Elseif strComp(retVal,"0",1) =0 Then
MsgBox n &" is not a Prime Number"
Else
MsgBox n &" is -ve Number"
End If
'-------------------
Function PrimeNo(x)
k=0
z=0
If strComp(n,"0",1) = 0 Then
PrimeNo = 0
Exit Function
Elseif n < 0 Then
PrimeNo = -1
Exit Function
End If
For i = 1 to x
IsPrime = 0
If strComp(x,"1",1)= 0 Then
PrimeNo = 0
Exit Function
End If
z = x mod i
If eval("z = 0") and strComp(i,x,1) <>0 and
strComp(i,"1",1) <> 0 Then
PrimeNo = 0
Exit Function
Else
IsPrime= 1
End If
Next
PrimeNo = IsPrime
End Function
'-----------------------------------
Is This Answer Correct ? | 0 Yes | 10 No |
Post New Answer View All Answers
The structure of keyword driven frame work is like a folder structure the different sub folder are 1-functional libray folder 2-object repository folder 3- database folder 4-appliction1.xls 5-initalzation vbs file 6-sequence file 7-driver script 8-test case list file My question is whether these are in a local server machine or in our pc.((whether It like Vss). can u give example of driver script(code)
What is the parameterization? Give one example?
give me the code to save all messages of inbox of gmail into a folder and notepad
what is the latest version of QTP? Main difference between 9.2 and 10 version
Diff b/w test scenario's and test Procedures?
What is the use of running the scripts in Hidden-mode in UFT?
what frame work you are following?
can u explain the keyword driven framework with an example clearly how to create all the files and how to attach to main test.
in qtp 3 sheets is there in data table like global, action1, action2. I want to check the rows and columns in action2. how can check using script?
Is it possible to refer the same object for referring more than one object that are of different class using the descriptive programming approach? Suppose my code is 'To create the object named as obj Set obj=Description.Create() 'To define the values obj("title").value="IE" obj("type").value="text" obj("html tag").value="INPUT" 'To set the value Browser("IE").Page("Yahoo").WebEdit(obj).Set "xyz" Can I refer the "obj" object for the three objects like Browser,page and webedit objects? If so how?
How to handle the exceptions using recovery secnario manager in quicktest professional (qtp)?
Is it possible to change the values of analog recording?
Explain sub procedure of vbscript.
What is the virtual object?
After executing the script in qtp suppose i found some script execute successfully and found some error.So how to report the status for both (i.e pass and fail report)in test director. For "fail" We use "defect tab" in testdirector. But for "pass" how to report it to TL.what is the process plz anybody ans