WORKING WITH QTP

TestEveryThinG

Get current DATETIME through VB QTP/Create unique file or folder

Posted by rajivkumarnandvani on April 17, 2009

Some Time we want create a folder Or File with unique name then we current date time value for creating the file or folder that we can use this method for create the file OR folder as decribed here

REM this function return the current date time in text format

REM  Function  fn_GetDateTimeText() This function return currentdatetime in Text format
REM  this will remove the specail charactor from currentdatetime & replace with _ underscore
REM  Input              := None
REM  Output(ReturnType) := return currentdatetime in Text format

Public Function fn_GetDateTimeText

Dim sDateTime
sDateTime = now
sDateTime =replace(sDateTime,”:”,”_”)
sDateTime =replace(sDateTime,”>”,”_”)
sDateTime =replace(sDateTime,”<“,”_”)
sDateTime =replace(sDateTime,”/”,”_”)
sDateTime =replace(sDateTime,”|”,”_”)
sDateTime =replace(sDateTime,”\”,”_”)
sDateTime =replace(sDateTime,”*”,”_”)
sDateTime =replace(sDateTime,””””,”_”)
sDateTime =replace(sDateTime,”#”,””)
fn_GetDateTimeText =sDateTime
End Function

dim sGetCurrentDateTime

sGetCurrentDateTime = fn_GetDateTimeText()

Set objFSO =CreateObject(“Scripting.FileSystemObject”)

rem create text file

objFSO.CreateTextFile(“c:/” & sGetCurrentDateTime & “.txt” , True)

rem create folder

objFSO.CreateFolder(“c:/” & sGetCurrentDateTime & “.txt” , True)

Advertisements

One Response to “Get current DATETIME through VB QTP/Create unique file or folder”

  1. Jodie said

    Many thanks for some great information, I’ve shared this page on Facebook.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: