Sunday, 31 July 2011

Dot Net factory


Working with Dot net factory or .Net classes

      Working with Dot net factory Or .net classes in QTP looks very difficult  to understand or its giving an impression that to use those classes we should have .net experience or this class will only help us on .net applications but my dear friends this is just a myth .You will come to know all in and out of using dot net factory as you go on with this article .

v  .net Date and time formatting

Using tostring

''create a data and time object
Set dateTime  = DotnetFactory ("System.DateTime")
Print "Time ( hh:mm tt MM/dd/yy) - " & DateTime.now.TouniversalTime.toString("hh:mm tt MM/dd/yy")
Set datetime =Nothing
So whatever format we can just give over here with the simple brackets after tostring and we can  get the required output .
Check the following QTP screen shots for more details.  

Using parse

Dim SystemDate , DateTime
Set SystemDate = Dotnetfactory.CreateInstance("System.DateTime")
Set DateTime = SystemDate.Parse("Fri, 9 Oct 2009 12:12")
FormattedDate = DateTime.Day & "/" & DateTime.Month & "/" & DateTime.Year &"/"& DateTime.hour&"/"& DateTime.minute
msgbox FormattedDate
Set SystemDate = Nothing
Set DateTime = Nothing




No comments:

Post a Comment