VB Script

'1    Print Hello World
Print "Hello World"

'2    Find whether given number is a odd number
Dim oNumber
oNumber=4
If oNumber mod 2 <>0 Then
    Print "The Number "& oNumber &" is an Odd Number"
else
    Print "The Number "& oNumber &" is not an Odd Number"
End If

'3    Print odd numbers between given range of numbers
Dim RangeStart
Dim RangeEnd
Dim iCounter
RangeStart=10
RangeEnd=20
For iCounter=RangeStart to RangeEnd
    If iCounter mod 2 <>0 Then
        Print  oNumber
    End If
Next
 

'4    Find the factorial of a given number
Dim oNumber
Dim iCounter
Dim fValue
oNumber=6
fValue=1
For iCounter=oNumber to 1 step-1
    fValue=fValue*iCounter
Next
print  fValue

'5    Find the factors of a given number
Dim oNumber
Dim iCounter
oNumber=10
For iCounter=1 to oNumber/2
    If oNumber mod iCounter=0 Then
        print iCounter
    End If
Next
print oNumber

'6    Print prime numbers between given range of numbers
Dim RangeStart
Dim RangeEnd
Dim iCounter
RangeStart=1
RangeEnd=30
For iCounter=RangeStart to RangeEnd
    For iCount=2 to round(iCounter/2)
            If iCounter mod iCount=0 Then
                Exit for
            End If
    Next
       If iCount=round(iCounter/2)+1 or iCounter=1 Then
            print iCounter
    End If
Next

'7    Swap 2 numbers with out a temporary variable
Dim oNum1
Dim oNum2
oNum1=1055
oNum2=155
oNum1=oNum1-oNum2
oNum2=oNum1+oNum2
oNum1=oNum2-oNum1
print oNum1
print oNum2

'8    Write a program to Perform specified Arithmetic Operation on two given numbersDim oNum1
Dim oNum2
Dim oValue
oNum1=10
oNum2=20
OperationtoPerform="div"
Select Case lcase(OperationtoPerform)
                Case "add"
                                oValue=oNum1+oNum2
                Case "sub"
                                oValue=oNum1-oNum2
                Case "mul"
                                oValue=oNum1*oNum2
                Case "div"
                                oValue=oNum1/ oNum2
End Select
print oValue

'9    Find the length of a given string
Dim oStr
Dim oLength
oStr="sudhakar"
oLength=len(oStr)
print oLength

'10    Reverse given string
Dim oStr
Dim oLength
Dim oChar
Dim iCounter
oStr="sudhakar"
oLength=len(oStr)
For iCounter=oLength to 1 step-1
        oChar=oChar&mid(oStr,iCounter,1)
Next
print oChar
      
Add and Remove Repositories to an Action In RunTime

Associate and Dissociate Object Repositories for An Action In RunTime

'Adding Repository to an action
 Dim qtApp,qtRepositories, actName, RepPath
 RepPath=".TRS File Path"
 actName=Environment.Value("ActionName")    'Get Action Name
 Set qtApp = CreateObject("QuickTest.Application")    ' Create Application Object
 Set qtRepositories = qtApp.Test.Actions(actName).ObjectRepositories    ' Get Associated repositories list
 If qtRepositories.Find(RepPath) = -1 Then
 qtRepositories.Add RepPath, 1    ' Add the Object Repository to the current action
 End If
 qtApp= Nothing
 qtRepositories= Nothing

'Remove repository from an action
 Dim qtApp,qtRepositories, actName, RepPath,  rPosition
 RepPath=".TRS File Path"
 actName=Environment.Value("ActionName") 'Get Action Name
 Set qtApp = CreateObject("QuickTest.Application")    ' Create Application Object
 Set qtRepositories = qtApp.Test.Actions(actName).ObjectRepositories    ' Get Associated repositories list
 rPosition=qtRepositories.Find(RepPath) 'Find the Position of the Repository
 If  rPosition<>-1 then
  qtRepositories.Remove rPosition  ' Remove Repository From the Action
 End if
 qtApp= Nothing
 qtRepositories= Nothing
 

No comments:

Post a Comment