Author Archives:

To Close all Internet Explorers

Before going to run your script needs to close all IEs,it helps you to work with QTP without any object /browser identification problems. just have a look here, Public function closeAllBrowsers() Dim qtStartTime, ieStartTime, strComputer, objWMIService,ieProcessList,qtProcessList strComputer = “.” Set objWMIService = GetObject(“winmgmts:\\” & strComputer & “\root\cimv2″) Set ieProcessList = objWMIService.ExecQuery (“Select * from Win32_Process [...]

Locale Settings

We can set as per our local time/zone,time formats… 1.SetLocale(lcid) a.if lcid=0 then the locale is set to match the current system setting Msgbox (SetLocale(0))–>1033 b.Msgbox (SetLocale(“en-gb”))–>1033 c.SetLocale(currentLocale)–>1033 Note:1033 denotes “English – United States” Zone by using this u can customize your time formats,zones,etc  

To Get repeat sequences of random numbers

Suppose if you want to test your application functionality with same repeated sequence of random number then use Rnd(-1) here use Rnd argument number as -1 Script: Dim MyValue, Response Randomize   ‘ Initialize random-number generator. Do Until Response = vbNo MyValue = Int((9 * Rnd(-1)) + 1)   ‘ Generate random value between 1 and 9. [...]

Find YOur Zone Time

‘If you want find specific local time zone. Function Local_TimeZone() Dim strComputer,oWMIService,oComputer, allColComputer strComputer = “.” Set oWMIService = GetObject(“winmgmts:” _ & “{impersonationLevel=impersonate}!\\” _ & strComputer & “\root\cimv2″) Set allColComputer = oWMIService.ExecQuery _ (“Select * from Win32_TimeZone”) For Each oComputer in allColComputer msgbox oComputer.Description Exit For Next Set oComputer = Nothing Set allColComputer = Nothing [...]

How to lock your system automatically

’If you want lock your sustem once your script running is done automatically just you call the below function. ‘If you want lick ur system(for manual users)save this function in a .VBS file and then give one double click. Function Lock_Mysystem() Dim oSys,Syscmd Set oSys = CreateObject(“WScript.Shell”) Syscmd = “%windir%\SYSTEM32\rundll32.exe user32.dll,LockWorkStation” oSys.Run Syscmd, 0, False [...]

Customize your excel

Function ExcelCustomization(resultsPath,Filename,nameSheet, rvalue) Set ExcelFile = CreateObject(“Excel.Application”) Set wb = ExcelFile.Workbooks.Open (resultsPath & Filename&”.xls”) ‘To  open  the  existing  work book ExcelFile.Visible=False wb.Sheets(nameSheet).select                                                                                                                                                                                                                  ‘To select  specific XL sheet RCols = wb.Sheets(nameSheet).UsedRange.Columns.Count  ‘To get  the  number of  columns used Rrows=wb.Sheets(nameSheet).UsedRange.Rows.Count    ‘To get  the  number of   rows used For cl=1 to RCols wb. Sheets(nameSheet).Cells(1,cl).Interior.ColorIndex = 53  ‘To set [...]

How to get a Specific string from an array

Suppose if you want to get a specific string within an array that you don’t know on which position it is located,in this case we can go for filter condition. Filter function help you to filter a specific sub string in a string Return Value: Returns a zero-based array containing a subset of a string [...]

Get Proper/Specific Text from a String

1. To get Position of 1st occurence of the string within the string mvar=Instr(“VB Script is fun!”,”is”) msgbox(mvar)’returns 1st occurence position of the string/letter within another string 2.To get specific length of the string MyVar = Mid(“VB Script is fun!”, mvar, 2) msgbox(MyVar)  ‘ Returns ” is” 3.Suppose if you want to get specific text [...]

Follow

Get every new post delivered to your Inbox.