Use a **For Loop** when you know the number of iterations in advance. Use **While..Do** when you want to continue looping as long as a condition is true, and you may not know how many times it will run. Use **Do..While** when you want to ensure the loop runs at least once before checking the condition.
"For" loop can be used when the range of the iteration is
known. For ex: For i = 1 to 100....
"While..do" or "do..While" can be used when, the scenario
should satisfy the condition.
For Ex: While (<Condition>)...
Dim StrFunVal
StrFunVal = fn_MyFunction(7)
Function fn_MyFunction(Num)
fn_MyFunction=Num+8
End Function
During the execution the "StrFunVal" variable will contain
the value 15. If you don't want to use 'Msgbox' or 'Print'
then declaring a variable is prefered.
For your other question I haven't come across returning
more than 1 value from functions. Probably we have to use a
ARRAY kind of stuff...but not sure. Need to work on it.
Cheers,
VGR
in VB Script
```vbscript
Function FindLargestValue(arr)
Dim largest, i
largest = arr(0)
For i = 1 To UBound(arr)
If arr(i) > largest Then
largest = arr(i)
End If
Next
FindLargestValue = largest
End Function
' Example usage
Dim numbers
numbers = Array(3, 5, 7, 2, 8)
Dim largestValue
largestValue = FindLargestValue(numbers)
WScript.Echo "The largest value is: " & largestValue
```
<?php
// define function largest()
function largest($numbers) {
foreach ($numbers as $temp) {
$largestNumber = max($numbers);
}
return $largestNumber;
} // end function
$numbers = array(3, 45, 2, 56, 7, 9, 78, 23, 63);
echo largest($numbers); // if you want you can echo or just
use it another function or programe
?>
To create a pull-down menu (drop-down list) in VBScript, you typically use HTML with a `<select>` element. Here's an example:
```html
<!DOCTYPE html>
<html>
<head>
<title>Pull Down Menu Example</title>
</head>
<body>
<form>
<label for="menu">Choose an option:</label>
<select id="menu" name="menu">
<option value="option1">Option 1</option>
<option value="option2">Option 2</option>
<option value="option3">Option 3</option>
</select>
</form>
</body>
</html>
```
In this example, the `<select>` element creates a pull-down menu with three options.
To insert a snapshot during manual scripting in QTP (QuickTest Professional), you can use the "Insert" menu option. Click on "Insert" and then select "Bitmap" to add a snapshot of the current screen to your test. Alternatively, you can use the keyboard shortcut "Ctrl + B" to quickly insert a bitmap snapshot.
We can use capturebitmap for this two inputs are there one is filetype means need to give path and type of image like png or bmp ("Ex:Login.png") and rest is true or false. true means if image is there with same name it will overwrite if not it creates the name which we have given..By default true is there.
Browser().page().capturebitmap("G:Login.png",true)
The function template concept in VB.NET is implemented using **Generics**.
1) VBScript can be used in testing applications by automating tasks such as UI interactions, data validation, and running test cases in tools like QTP (QuickTest Professional) or UFT (Unified Functional Testing).
2) To learn VBScript, you need to have a PC with a text editor (like Notepad), a web browser (for testing scripts in HTML), and optionally, testing tools like QTP/UFT or any other automation framework that supports VBScript.
A good tutorial for learning VBScript for QTP (QuickTest Professional) is the official Micro Focus UFT (Unified Functional Testing) documentation, as well as online resources like the "VBScript Tutorial" on W3Schools and the "VBScript for QTP" section on Guru99.
for VBScript in QTP orientation visit:
www.gcreddy.com
there you can get:
VBScript examples,
GUI Scripts,
Web Scripts,
Database scripts,
Excel scripts,
Flat files scripts etc..
It is a very useful site for QTP advanced learners.
str="krishna radha"
a=left(str,7)
c=Replace(a,"k","K")
b=right(str,5)
d=Replace(b,"r","R")
msgbox d&" "&c
str="krishna radha"
A=Split(str," ")
Fstring=A(0)
Lstring=A(1)
sLString=replace(Lstring,"r","R")
sFString=replace(Fstring,"k","K")
Rstring=sLString&" "&sFString
MsgBox Rstring
The above VB Script is exact ans for this question.
U can get the value by using Object Spy and get the properties
which ever u want.
we can test the frequently changed object like links or
buttons...etc with the help of DP...
we can test dynamicly changed links with help of DP with
Reg.Exp or creation of time.
Set link = Description.Create()
link("innertext").Value = "xxx"
link("innertext").Reg.Exp = "xxx"
Browser(Broswer).page(Page).weblink(link).click
if page object is given then..
eg> set pgObj = browser(yahoo).page(yahoo)
pgObj - is the page object
Answers:
1. we can check for the page as follows
tmpPageName = pgObj.getroproperty("name")
if tmpPageName = "Yahoo" then
msgbox "Found the page"
else
msgbox "Page Not found"
end if
2. Need to use description.create function
set descObj = description.create
descObj("micclass").value ="link"
set lnkObj = pgObj.childobjects(descObj)
msgbox lnkObj.count '// This will give you number of links
found in that page
I dont know the rite answer for this question,. But this
question will be very much useful to know more about the
main testing tool QTP,.
it means the impact of front end operations on the backend
tables that is the data validation and the data integrity
(i.e the opetations like inserting, and updating and
deleting whatever the operations that should affect in the
backend tables)
A database checkpoint checks the contents of databases
accessed by your web site
I am having the same problem. I tried with the above code
and also put wait() statement in the code. Nothing works.
It would be greatly appreciated, if someone help with this.
ByRef refers to the location, ByVal refers to the actual value. Also, if you are passing parameters with "ByVal" then even if the parameter values are changed, the original argument values will remain intact. But if you pass using "ByRef" then if the parameter values are changed, then the original argument value is also modified
Byval refers to the actual value of the variable. ByRef
refers to the location of where the value is stored.
Passing.
The VBScript category on takluu.com is designed for IT professionals and developers who want to strengthen their skills in Visual Basic Scripting Edition (VBScript). VBScript is a lightweight scripting language primarily used for automation, web development, and administrative tasks in Windows environments.
This section covers essential topics such as VBScript syntax, variables, data types, control structures (loops and conditionals), functions, error handling, and interaction with the Windows operating system. You will also find questions on file handling, working with objects, and automating routine tasks using VBScript.
Interviewers often focus on practical scripting skills, asking questions like:
-
“How do you write a loop in VBScript?”
-
“Explain error handling in VBScript.”
-
“How can VBScript be used to automate system tasks?”
Our content explains VBScript concepts clearly, providing examples and scripts that make it easier to understand and apply. Whether you are preparing for an automation role or a developer position, this category helps you build confidence and master VBScript fundamentals.
At Takluu, we regularly update the VBScript category with new questions, coding examples, and best practices, keeping you prepared for scripting-related interviews and tasks.