Hello Friends
I wrote a simple *.vbs function to get the file name of last two modified
file and getting an error while retriving the value from the array. The
error code is shared in the attached attachment and VB code is shared below:
msgbox Isarray (GetFilename)
msgbox UBound (GetFilename)
msgbox LBound (GetFilename)
abc = GetFilename(0)
msgbox abc
msgbox GetFilename(LBound (GetFilename))
msgbox GetFilename(UBound (GetFilename))
'msgbox GetFilename(0) & "------------->" & GetFilename(1)
Function GetFilename()
Dim objShell
Dim strPath
Dim objFSO
Dim objFile
Dim GetCurrentFolderPath
Dim objFolder
Dim Flag
Dim FileItem
Dim Filename
ReDim Filename(1)
Dim Filename1
Dim File1
Dim Filename2
Dim File2
Set objShell = CreateObject("Wscript.Shell")
strPath = Wscript.ScriptFullName
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile(strPath)
GetCurrentFolderPath = objFSO.GetParentFolderName(objFile)
Set objFolder = objFSO.GetFolder(GetCurrentFolderPath)
Flag = 1
For Each FileItem In objFolder.Files
If FileItem.DateLastModified > File1 Then
File1 = FileItem.DateLastModified
Filename1 = FileItem.Name
If Flag = 1 Then
File2 = FileItem.DateLastModified
Filename2 = FileItem.Name
Flag = Flag + 1
End If
End If
If FileItem.DateLastModified > File2 And FileItem.DateLastModified
< File1 Then
File2 = FileItem.DateLastModified
Filename2 = FileItem.Name
End If
Next
Filename(LBound(Filename)) = Filename1
Filename(UBound(Filename)) = Filename2
GetFilename = Filename
Set objFolder = Nothing
Set objFile = Nothing
Set objFSO = Nothing
Set objShell = Nothing
End Function
--
Best regards,
Vishal Gupta
+919989475211
--
--
You received this message because you are subscribed to the Google
"QTP - HP Quick Test Professional - Automated Software Testing"
group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/MercuryQTP?hl=en
---
You received this message because you are subscribed to the Google Groups "QTP
- HP Quick Test Professional - Automated Software Testing" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.