Search This Blog

Wednesday 16 January 2013

Finding Current Month Last Date DAY name ?

Dim mon,a
mon=Month(Now)
curDate=date
'MsgBox curDate
YY=year(curDate)
Y=YY
Select Case mon
Case "1" 
  MsgBox "Jan"
  j="31-01-"&Y
  MsgBox j
Case "2"  
  MsgBox "Feb"
  j="28-02-"&Y
  MsgBox j
Case "3"
  MsgBox "Mar"
  j="31-03-"&Y
  MsgBox j
Case "4" 
  MsgBox "April"
  j="30-04-"&Y
  MsgBox j
Case "5"  
  MsgBox "May"
  j="31-05-"&Y
  MsgBox j
Case "6"
  MsgBox "June"
  j="30-06-"&Y
  MsgBox j
Case "7" 
  MsgBox "July"
  j="31-07-"&Y
  MsgBox j
Case "8"  
  MsgBox "Aug"
  j="31-08-"&Y
  MsgBox j
Case "9"
  MsgBox "Sep"
  j="30-09-"&Y
  MsgBox j
Case "10" 
  MsgBox "Oct"
  j="31-10-"&Y
  MsgBox j
Case "11"  
  MsgBox "Nov"
  j="30-11-"&Y
  MsgBox j
Case "12"
  MsgBox "Dec"
  j="31-12-"&Y
  MsgBox j
End Select
c=Weekday(j)
a=WeekdayName(c)
MsgBox a

Note : You can check this code by changing the system date in different years.

Finding RAM size using QTP Program?

Dim Wshshell,fso,fo,l
''Open the CMD Prompt
set WshShell = CreateObject("WScript.Shell")
SystemUtil.run "cmd.exe"
wait(2)
'cmd="systeminfo |find"
'cmd1="Total Physical Memory:"
'WshShell.SendKeys cmd &" "&"""" &cmd1&""""
WshShell.SendKeys "systeminfo |find"&" "&""""&"Total Physical Memory:"&""""&">D:\Sys.txt"
WshShell.SendKeys "~"
wait(3)

WshShell.SendKeys "exit"
WshShell.SendKeys "~"


                        Set fso=createobject("scripting.filesystemobject")
                        Set fo=fso.opentextfile("D:\Sys.txt")
While fo.AtEndOfStream<>true
                                    l=fo.readline
                                    MsgBox l
                        wend
                        fo.close
                        set fo=nothing
                        set fso=nothing

Sorting Data in Excel Sheet ?

Dim exo,wbo,wso
Set exo=createobject("Excel.application")
Set wbo=exo.Workbooks.Open("E:\number.xlsx")
Set wso=wbo.Worksheets("Sheet1")
exo.Visible=true
wait(3)

Set objRange = wso.UsedRange
Set objRange2 = exo.Range("A1")
objRange.Sort(objRange2)
wbo.Save
exo.Quit
Set wbo=nothing
Set wso=nothing
Set exo=nothing

Note: Indicated "A1" as the starting point in Excel.