Dim MyValue, MyVal, MyReturn
MyValue = "Welocme To All"
MyReturn = TypeName(MyVal)
MsgBox MyReturn
MyReturn = TypeName(MyValue)
MsgBox MyReturn
Thursday, June 3, 2010
Difference between Fix and Int
Dim MyValue, MyVal, MyReturn
MyVal = -9874.43875
MyReturn = Fix(MyVal)
MsgBox MyReturn
MyReturn1 = Int(MyVal)
MsgBox MyReturn1
MyVal = -9874.43875
MyReturn = Fix(MyVal)
MsgBox MyReturn
MyReturn1 = Int(MyVal)
MsgBox MyReturn1
Generate a Random Number
Dim MyString, MyReturn
MyReturn = 10
MyValue = Int((100 * Rnd) + 1)
MsgBox MyValue
If (MyValue = MyRetrun) Then
MsgBox " Equal"
Else
MsgBox " Not Equal"
End If
MyReturn = 10
MyValue = Int((100 * Rnd) + 1)
MsgBox MyValue
If (MyValue = MyRetrun) Then
MsgBox " Equal"
Else
MsgBox " Not Equal"
End If
Format Number to specified decimal places
Dim MyValue, MyReturn
MyValue = 93864934.0238923
MyReturn = Round(MyValue, 10)
MsgBox MyReturn
Or
IF you were entered more Decimal value,System thru error message
MyValue = 93864934.0238923
MyReturn = Round(MyValue, 100)
MsgBox MyReturn
MyValue = 93864934.0238923
MyReturn = Round(MyValue, 10)
MsgBox MyReturn
Or
IF you were entered more Decimal value,System thru error message
MyValue = 93864934.0238923
MyReturn = Round(MyValue, 100)
MsgBox MyReturn
Find leap year
Dim MyYear
'MyYear = Year(Date)
MyYear = 2016
If (MyYear / 4 = MyYear \ 4) Then
MsgBox " Leap Year"
Else
MsgBox "Not a Leap Year"
End If
'MyYear = Year(Date)
MyYear = 2016
If (MyYear / 4 = MyYear \ 4) Then
MsgBox " Leap Year"
Else
MsgBox "Not a Leap Year"
End If
Print current day of the week
Dim MyDate, MyReturn
MyDate = "January 11, 1981"
MyReturn = Weekday(MyDate, vbSunday)
MsgBox MyReturn
(Or)
Dim MyDate, MyReturn
MyDate = Date
MsgBox MyDate
MyReturn = Weekday(MyDate, vbUseSystemDayOfWeek)
MsgBox MyReturn
MyDate = "January 11, 1981"
MyReturn = Weekday(MyDate, vbSunday)
MsgBox MyReturn
(Or)
Dim MyDate, MyReturn
MyDate = Date
MsgBox MyDate
MyReturn = Weekday(MyDate, vbUseSystemDayOfWeek)
MsgBox MyReturn
Add time interval to a date
Dim MyDate, MyReturn
MyDate = "January 11, 1981"
MyReturn = DateAdd("YYYY", 29, MyDate)
MsgBox MyReturn
MyDate = "January 11, 1981"
MyReturn = DateAdd("YYYY", 29, MyDate)
MsgBox MyReturn
Find difference between two dates.
Dim MyDate, MyReturn
MyDate = "January 11, 1981"
MyCurDate = Date
MyReturn = DateDiff("YYYY", MyDate, MyCurDate)
MsgBox MyReturn
MyDate = "January 11, 1981"
MyCurDate = Date
MyReturn = DateDiff("YYYY", MyDate, MyCurDate)
MsgBox MyReturn
Display current date and Time
Dim MyDate, MyTime
MyDate = Date
MsgBox MyDate
MyTime = Time
MsgBox MyTime
MyDate = Date
MsgBox MyDate
MyTime = Time
MsgBox MyTime
Convert an expression to a date
Dim MyDate, MyReturn
MyDate = "January 11, 1981"
MyReturn = CDate(MyDate)
MsgBox MyReturn
MyDate = "January 11, 1981"
MyReturn = CDate(MyDate)
MsgBox MyReturn
Convert value into a currency
Dim MyValue, MyReturn
MyValue = 3583587
MyReturn = FormatCurrency(MyValue)
MsgBox MyReturn
MyValue = 3583587
MyReturn = FormatCurrency(MyValue)
MsgBox MyReturn
Find whether a variable is an Array
Dim MyString As Variant, MyReturn As Variant
MyString = Array(10, 20, 30)
If (IsArray(MyString)) Then
MsgBox "True"
Else
MsgBox "False"
End If
MyString = Array(10, 20, 30)
If (IsArray(MyString)) Then
MsgBox "True"
Else
MsgBox "False"
End If
program to force the declaration of variables
Option Explicit
Dim MyString, MyReturn
MyString = " VBScript is fun! "
'MyReturn = Trim(MyString)
MsgBox MyReturn
Dim MyString, MyReturn
MyString = " VBScript is fun! "
'MyReturn = Trim(MyString)
MsgBox MyReturn
Trim a given string
Dim MyString, MyReturn
MyString = " VBScript is fun! "
MyReturn = Trim(MyString)
MsgBox MyReturn
MyReturn2 = LTrim(MyString)
MsgBox MyReturn2
MyReturn1 = RTrim(MyString)
MyString = " VBScript is fun! "
MyReturn = Trim(MyString)
MsgBox MyReturn
MyReturn2 = LTrim(MyString)
MsgBox MyReturn2
MyReturn1 = RTrim(MyString)
Write a program to reverse the words of a given string
Dim MyString, MyReturn
MyString = "VBScriptXisXfun!"
MyReturn = StrReverse(MyString)
MsgBox MyReturn
MyString = "VBScriptXisXfun!"
MyReturn = StrReverse(MyString)
MsgBox MyReturn
Find number of words in string
Dim MyString, MyReturn
MyString = "VBScriptXisXfun!"
MyReturn = Len(MyString)
MsgBox MyReturn
MyString = "VBScriptXisXfun!"
MyReturn = Len(MyString)
MsgBox MyReturn
Verify whether given two strings are equal
Dim MyString1, MyString2
MyString1 = ("India")
MyString2 = ("India")
MyReturn = StrComp(MyString1, MyString2, vbTextCompare)
If (MyReturn = 1) Then
MsgBox MyReturn & " string1 is greater than string2"
ElseIf (MyReturn = 0) Then
MsgBox MyReturn & "string1 is equal to string2"
ElseIf (MyReturn = -1) Then
MsgBox MyReturn & "string1 is less than string2"
Else
MsgBox MyReturn & "string1 or string2 is Null"
End If
MyString1 = ("India")
MyString2 = ("India")
MyReturn = StrComp(MyString1, MyString2, vbTextCompare)
If (MyReturn = 1) Then
MsgBox MyReturn & " string1 is greater than string2"
ElseIf (MyReturn = 0) Then
MsgBox MyReturn & "string1 is equal to string2"
ElseIf (MyReturn = -1) Then
MsgBox MyReturn & "string1 is less than string2"
Else
MsgBox MyReturn & "string1 or string2 is Null"
End If
Replace a word with another word
Dim MyString, MyInput, MyReturn
MyString = UCase("Welocme To India")
MyInput = UCase("ALL")
MyReturn = Replace(MyString, "INDIA", MyInput)
MsgBox MyReturn
MyString = UCase("Welocme To India")
MyInput = UCase("ALL")
MyReturn = Replace(MyString, "INDIA", MyInput)
MsgBox MyReturn
Find whether given number is an odd number
If (a / 2 = a \ 2) Then
MsgBox a & "Even Number"
Else
MsgBox a & "Add Number"
End If
MsgBox a & "Even Number"
Else
MsgBox a & "Add Number"
End If
Find occurrences of a specific character in a string
Dim MyString
MyString = "welcome"
MyReturn = Left(MyString, 1)
MsgBox MyReturn
MyString = "welcome"
MyReturn = Left(MyString, 1)
MsgBox MyReturn
Return the reverse a string or number
a = 987654321
b = StrReverse(a)
MsgBox b
Aa = "llA ot emoclew"
Bb = StrReverse(Aa)
MsgBox Bb
b = StrReverse(a)
MsgBox b
Aa = "llA ot emoclew"
Bb = StrReverse(Aa)
MsgBox Bb
Arithmetic Operation on two given numbers
Dim a, b, c, result
a = 10
b = 2
result = a + b
MsgBox result
result = a - b
MsgBox result
result = a / b
MsgBox result
result = a * b
MsgBox result
result = a ^ b
MsgBox result
a = 10
b = 2
result = a + b
MsgBox result
result = a - b
MsgBox result
result = a / b
MsgBox result
result = a * b
MsgBox result
result = a ^ b
MsgBox result
Print odd numbers between given range of numbers
For i = 0 To 100 Step 1
If (i / 2 = i \ 2) Then
MsgBox i & "Even Number"
Else
MsgBox i & "Add Number"
End If
Next
If (i / 2 = i \ 2) Then
MsgBox i & "Even Number"
Else
MsgBox i & "Add Number"
End If
Next
Program to Import an excel file to a Data table
Datatable.import(“C:\Test\Excel.xlsx”)
Program to Read data from first parameter of Global sheet
Browser(Obj).Page(Obj).WebEdit(Obj).Select Cint(DataTable(“UserName”,”GlobalSheet”)
(Or)
DataTable.Value(“UserName”,”Globalsheet”)
Program to Read data from first parameter of Global sheet
Browser(Obj).Page(Obj).WebEdit(Obj).Select Cint(DataTable(“UserName”,”GlobalSheet”)
(Or)
DataTable.Value(“UserName”,”Globalsheet”)
Write a program to Invoke the Browser with specified URL
systemutil.Run "iexplore.exe", www.naukri.com
Write a program to find whether image contains tool tip
msgbox Browser("Naukri.com - Search Jobs").Page("Google Image Result for").Image("See full size image").GetROProperty("alt")
Invoke the Browser with specified URL
Invokeapplication “C:\Programfiles\Internet Explorer\IEXPLORE.EXE”
Browser(Obj).Enter http://www.google.com
Browser(Obj).Enter http://www.google.com
Write a program to Check given text is displayed on the web page
Const Val = "My Nakuri"
a = Browser("Naukri.com - Search Jobs").GetROProperty("title")
If strcomp(a,Val,0) Then
Reporter.ReportEvent micPass,"Browser Title", "Is Equal"
else
Reporter.ReportEvent micFail,"Browser Title", "Is Not Equal"
End If
a = Browser("Naukri.com - Search Jobs").GetROProperty("title")
If strcomp(a,Val,0) Then
Reporter.ReportEvent micPass,"Browser Title", "Is Equal"
else
Reporter.ReportEvent micFail,"Browser Title", "Is Not Equal"
End If
Verify page title is displayed correctly
Const Val = "My Nakuri"
a = Browser("Naukri.com - Search Jobs").GetROProperty("title")
If strcomp(a,Val,0) Then
Reporter.ReportEvent micPass,"Browser Title", "Is Equal"
else
Reporter.ReportEvent micFail,"Browser Title", "Is Not Equal"
End If
a = Browser("Naukri.com - Search Jobs").GetROProperty("title")
If strcomp(a,Val,0) Then
Reporter.ReportEvent micPass,"Browser Title", "Is Equal"
else
Reporter.ReportEvent micFail,"Browser Title", "Is Not Equal"
End If
Write a program to refresh a web page
Browser(Obj).Refresh
Print URL displayed in the address bar
Furl = Browser(Obj).GetRoPerperty(“OpenURL”)
Msgbox Furl
(OR)
a= Browser("Naukri.com - Search Jobs").Page("My Naukri_3").Object.links
msgbox a
a= Browser("Naukri.com - Search Jobs").Page("My Naukri_3").Object.url
msgbox a
Msgbox Furl
(OR)
a= Browser("Naukri.com - Search Jobs").Page("My Naukri_3").Object.links
msgbox a
a= Browser("Naukri.com - Search Jobs").Page("My Naukri_3").Object.url
msgbox a
Find image width and Height
fwid = Browser(Obj).Page(Obj).Image(Obj).GetRoPerperty(“Width”)
fhig = Browser(Obj).Page(Obj).Image(Obj).GetRoPerperty(“Height”)
(OR)
msgbox Window("Flight Reservation").WinRadioButton("Business").GetROProperty("width")
msgbox Window("Flight Reservation").WinRadioButton("Business").GetROProperty("height")
fhig = Browser(Obj).Page(Obj).Image(Obj).GetRoPerperty(“Height”)
(OR)
msgbox Window("Flight Reservation").WinRadioButton("Business").GetROProperty("width")
msgbox Window("Flight Reservation").WinRadioButton("Business").GetROProperty("height")
Program to check whether given link exists
IF (Browser(Obj).Page(Obj).Link(Obj).Exists) then
Report.reportevent “Link Exists in the Page”
Else
Report.reportevent “Link not Exists in the Page”
End if
Report.reportevent “Link Exists in the Page”
Else
Report.reportevent “Link not Exists in the Page”
End if
Write a program to select all the Radio button
Set ODecButton = Description.Create()
ODecButton("Class Name").value = "WinRadioButton"
Set butcnt = Window("Flight Reservation").ChildObjects(ODecButton)
nobutcnt = butcnt.count()
msgbox nobutcnt
For i=0 to nobutcnt -1 step 1
butcnt(i).set
Next
ODecButton("Class Name").value = "WinRadioButton"
Set butcnt = Window("Flight Reservation").ChildObjects(ODecButton)
nobutcnt = butcnt.count()
msgbox nobutcnt
For i=0 to nobutcnt -1 step 1
butcnt(i).set
Next
Capture web button image
Browser(Obj).Page(Obj).Webbutton(Obj).Capturbitmap “C:\Test\Webbuttonimage.bmp”,True
(OR)
window("Flight Reservation").WinButton("FLIGHT").CaptureBitmap "C:\buttonimage.bmp",True
(OR)
window("Flight Reservation").WinButton("FLIGHT").CaptureBitmap "C:\buttonimage.bmp",True
Write a program to Capture Desktop Screen shot
‘ Minimize the all the window and will show desktop
SystemUtil.Run "C:\Documents and Settings\MDV\Application Data\Microsoft\Internet Explorer\Quick Launch\Show Desktop.scf","","","open"
Desktop.CaptureBitmap("C:\rr1.bmp")
SystemUtil.Run "C:\Documents and Settings\MDV\Application Data\Microsoft\Internet Explorer\Quick Launch\Show Desktop.scf","","","open"
Desktop.CaptureBitmap("C:\rr1.bmp")
Check default selection in a list box
Comboval = window("Flight Reservation").WinComboBox("Fly From:").GetItem(0)
If (comboval = null) Then
Reporter.ReportEvent 0,"Combo box"," have Default Value"
else
Reporter.ReportEvent 1,"Combo box"," Not Null "
End If
If (comboval = null) Then
Reporter.ReportEvent 0,"Combo box"," have Default Value"
else
Reporter.ReportEvent 1,"Combo box"," Not Null "
End If
Program to check whether edit box is focused
IF ( Browser(Obj).Page(Obj).Webedit(Obj).Fireevent (“Onmouseover”) then
Msgbox “ Web edit is focused”
Else
Msgbox “ Web edit is not focused”
End if
(OR)
ChkEd = Dialog("Login").WinEdit("Agent Name:").GetROProperty("enabled","visiable")
IF(ChkEd = True) then
Reporter.ReportEvent micPass,"Agent Name Edit Button", "Object is Visiable and Enabled"
else
Reporter.ReportEvent micPass,"Agent Name Edit Button", " Object is not Visiable and Enabled"
End if
Msgbox “ Web edit is focused”
Else
Msgbox “ Web edit is not focused”
End if
(OR)
ChkEd = Dialog("Login").WinEdit("Agent Name:").GetROProperty("enabled","visiable")
IF(ChkEd = True) then
Reporter.ReportEvent micPass,"Agent Name Edit Button", "Object is Visiable and Enabled"
else
Reporter.ReportEvent micPass,"Agent Name Edit Button", " Object is not Visiable and Enabled"
End if
Program to check whether edit box is enabled or writable
MyString = Browser(Obj).Page(Obj).WebEdit(Obj).GetRoPerperty(“Visible)
IF (MyString = 1 or True) then
Msgbox & “ WedEdit is Visible: “ & Mystring
Else
Msgbox & “ WedEdit is not visible: “ & Mystring
End if
IF (MyString = 1 or True) then
Msgbox & “ WedEdit is Visible: “ & Mystring
Else
Msgbox & “ WedEdit is not visible: “ & Mystring
End if
Write a program to Read items on a desktop
‘ Minimize the all the window and will show desktop –
SystemUtil.Run "C:\Documents and Settings\MDV\Application Data\Microsoft\Internet Explorer\Quick Launch\Show Desktop.scf","","","open"
a= window("regexpwndtitle:=Program Manager").WinListView("object class:=SysListView32" ).GetROProperty("all items")
msgbox a
For i =0 to 10
myarray = split(a)
'msgbox myarray
b= trim(myarray(i))
msgbox b
next
SystemUtil.Run "C:\Documents and Settings\MDV\Application Data\Microsoft\Internet Explorer\Quick Launch\Show Desktop.scf","","","open"
a= window("regexpwndtitle:=Program Manager").WinListView("object class:=SysListView32" ).GetROProperty("all items")
msgbox a
For i =0 to 10
myarray = split(a)
'msgbox myarray
b= trim(myarray(i))
msgbox b
next
Write a Program to Read items in a Combo Box
For i=1 to Lists-1
Lists =window("regexpwndtitle:=Flight Reservation").WinComboBox("attached text:=Fly From:").GetItem(i)
msgbox lists
if (Lists = Null) Then
Exit for
End if
Next
Lists =window("regexpwndtitle:=Flight Reservation").WinComboBox("attached text:=Fly From:").GetItem(i)
msgbox lists
if (Lists = Null) Then
Exit for
End if
Next
Write a program to find the x and y coordinates of a button
Dim MyReturn,MyReturn1
MyReturn = Browser(Obj).GetRoPerperty(“X”)
Msgbox Myreturn
MyReturn1 = Browser(Obj).GetRoPerperty(“Y”)
Msgbox MyReturn1
MyReturn = Browser(Obj).GetRoPerperty(“X”)
Msgbox Myreturn
MyReturn1 = Browser(Obj).GetRoPerperty(“Y”)
Msgbox MyReturn1
Subscribe to:
Posts (Atom)