Function RegExpTest(patrn, strng)
Dim regEx, Match, Matches ' Create variable.
Set regEx = New RegExp ' Create a regular expression.
regEx.Pattern = patrn ' Set pattern.
regEx.Global = True ' Set global applicability.
Set Matches = regEx.Execute(strng) ' Execute search.
For Each Match in Matches ' Iterate Matches collection.
RetStr = RetStr & Match.Value' & vbCRLF
Next
RegExpTest = RetStr
End Function
a=(RegExpTest("[0-9]", "wipro123xyz45"))
msgbox(a)
Custom Search
Thursday, October 21, 2010
Wednesday, October 20, 2010
Regular expression for date formate (mm/dd/yy)
[1-9]|1[0-2]/[1-9]|[1-2][0-9]|3[0-1]/[0-9][0-9] ------12/10/99
^([1-9]|1[0-2])[-/.]([1-9][1-2][0-9]3[0-1])/[-/.](19[0-9][0-9]|20[0-9][0-9])$ ----- 12(-/.)10(-/.)1999
| Indicates a choice between two items.
^([1-9]|1[0-2])[-/.]([1-9][1-2][0-9]3[0-1])/[-/.](19[0-9][0-9]|20[0-9][0-9])$ ----- 12(-/.)10(-/.)1999
| Indicates a choice between two items.
how to compare two excell sheets by using vbscript??
Set objExcel = CreateObject("Excel.application")
objExcel.Visible = True
Set objWorkbook1 = objExcel.workbooks.Open("C:\First.xls")
Set objWorkbook2 = objExcel.workbooks.Open("C:\Second.xls")
Set objWorksheet1 = objWorkbook1.worksheets(1)
Set objWorksheet2 = objWorkbook2.worksheets(1)
For Each cell In objWorksheet1.UsedRange
If cell.Value <> objWorksheet2.Range(cell.Address).Value Then
msgbox "value is different"
Else
msgbox "value is same"
End If
Next
objWorkbook1.close
objWorkbook2.close
objExcel.quit
set objExcel=nothing
objExcel.Visible = True
Set objWorkbook1 = objExcel.workbooks.Open("C:\First.xls")
Set objWorkbook2 = objExcel.workbooks.Open("C:\Second.xls")
Set objWorksheet1 = objWorkbook1.worksheets(1)
Set objWorksheet2 = objWorkbook2.worksheets(1)
For Each cell In objWorksheet1.UsedRange
If cell.Value <> objWorksheet2.Range(cell.Address).Value Then
msgbox "value is different"
Else
msgbox "value is same"
End If
Next
objWorkbook1.close
objWorkbook2.close
objExcel.quit
set objExcel=nothing
Tuesday, September 21, 2010
Diff B/w Actions and Functions
1.Action is a specific to QTP while functions are a generic thing which is a feature of VB Scripting. 2.Action have a object repository, Data table etc associated with it while a function can't. 3.A function is just lines of code with some/none parameters and a single return value while an action can have more than one input/output parameters.
Open a Google page without using systemUtil.Run command?
Dim wsh
Set Wsh = CreateObject("Wscript.Shell")
Wsh.run "iexplore google.com"
Set Wsh = CreateObject("Wscript.Shell")
Wsh.run "iexplore google.com"
Monday, September 20, 2010
write the code to reverse a string without using Strrev built in function.
Dim i
Dim iStrLen
Dim strOut
Dim strTmp
Dim strMyString
strString=("Please enter the string to be reversed:")
iStrLen = Len(strString)
For i = 0 To Len(strString) - 1
strOut = Mid(strString, iStrLen - i, 1)
strTmp = strTmp & strOut
Next
strMyString = strTmp
msgbox strMyString
--------------------Second Scenario-----------
MyStr = inputbox("Enter the String:")
nCnt = Len(MyStr)
For i = 1 to nCnt
RevStr = Mid(MyStr,i,1)&RevStr
Next
Msgbox RevStr
-------------Third Scenario---------------
Dim yourstr,r,letter,result
yourstr="Automation"
Set r=new regexp
r.pattern="[a-z 0-9 A-Z]"
r.global=true
set s=r.execute(yourstr)
For each i in s
result= i.value&result
Next
msgbox result
Dim iStrLen
Dim strOut
Dim strTmp
Dim strMyString
strString=("Please enter the string to be reversed:")
iStrLen = Len(strString)
For i = 0 To Len(strString) - 1
strOut = Mid(strString, iStrLen - i, 1)
strTmp = strTmp & strOut
Next
strMyString = strTmp
msgbox strMyString
--------------------Second Scenario-----------
MyStr = inputbox("Enter the String:")
nCnt = Len(MyStr)
For i = 1 to nCnt
RevStr = Mid(MyStr,i,1)&RevStr
Next
Msgbox RevStr
-------------Third Scenario---------------
Dim yourstr,r,letter,result
yourstr="Automation"
Set r=new regexp
r.pattern="[a-z 0-9 A-Z]"
r.global=true
set s=r.execute(yourstr)
For each i in s
result= i.value&result
Next
msgbox result
what is the script to select 2 or more than 2 options from a listbox.
Browser().Page.().weblist().Select " "
Browser().Page.().weblist().Extendselect " "
by using extendselect method we can select more than one at a time from list box.
Browser().Page.().weblist().Extendselect " "
by using extendselect method we can select more than one at a time from list box.
Subscribe to:
Posts (Atom)