Custom Search

Sunday, January 9, 2011

How to add all array values without using “&” symbol?

Using Join method, add all array value to one string as below.

Dim Mystring
Dim Myarray(2)
Myarray(0)="Mr."
Myarray(1)="Jhon"
Myarray(2)="Deo"

Mystring=join(Myarray)
msgbox Mystring

Difference between Smoke and Sanity Testing?

Smoke Testing : - Smoke Testing done to ensure that whether the build can be accepted for further software testing or not. Basically, it is done to check the stability of the build received for software testing.

Sanity testing : - After receiving a build with minor changes in the code or functionality, check whether it rectified the  bugs or issues and any other bugs is introduced by the changes. and also test some of the functionalities in depth to ensure that whether the requirements are met or not.

Sunday, January 2, 2011

Get the repeated character in one string

Function GetCharCount(strChar,strSearchIn)
    dim intCounter
    for intCounter = 1 to len(strSearchIn)
         if Mid(strSearchIn,intCounter,1)=strChar then
             GetCharCount=GetCharCount+1
         end if
    next
End Function
msgbox GetCharCount("s", "this is a string")

======Second method=========
str="this is a string"
msgbox Len(str)-Len(Replace(str,"s",""))


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

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.