Custom Search

Thursday, October 21, 2010

Suppose I’m having a string wipro123xyz45 I need to get the value 12345 only from the string and the string could be changed randomly

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)

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.

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