Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
MsgBox not showing
#2
Solved: 10 Years, 11 Months, 1 Week ago
Thats because there is no error encountered and hence the IF loop is not satisfied. Only on an error would the err.number will bring up an error number and traverse into the loop. When there was no error encountered it skipped the If loop and went to the next line. However the copy has already happened outside of the loop and hence you see that behaviour.
You have to use an Else to skip the If condition and put up your msgbox there.
Code:
Dim FSO
Set FSO = CreateObject("Scripting.FileSystemObject")
On Error Resume Next
FSO.CopyFolder "C:\Program Files\Test", "E:\Test"

If err.number <> 0 Then
    FSO.CreateFolder "E:\Test"
    FSO.CopyFolder "C:\Program Files\Test", "E:\Test"    
Else
   MsgBox "Folder Copied"
End If

you could see that the folder is not copied if you try this code below,
Code:
Dim FSO
Set FSO = CreateObject("Scripting.FileSystemObject")
On Error Resume Next

If err.number <> 0 Then
    FSO.CreateFolder "E:\Test"
    FSO.CopyFolder "C:\Program Files\Test", "E:\Test"    
         msgbox "Files Copied"
End If
Basanth
Give a fish to a man and you feed him for a day..Teach a man how to fish and you feed him for life.
Reply


Messages In This Thread
MsgBox not showing - by arescool - 06-12-2013, 01:22 PM
RE: MsgBox not showing - by basanth27 - 06-12-2013, 02:08 PM
RE: MsgBox not showing - by arescool - 06-12-2013, 02:28 PM
RE: MsgBox not showing - by basanth27 - 06-12-2013, 03:19 PM
RE: MsgBox not showing - by vinod123 - 06-13-2013, 03:12 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Disabled Webelement is showing up as Visible =True in GUI Spy Shwethareddy 3 3,639 11-07-2012, 02:45 PM
Last Post: Ankesh
  get all text showing on web page daniel_QTP 3 13,864 09-25-2012, 12:44 PM
Last Post: jesonvan

Forum Jump:


Users browsing this thread: 1 Guest(s)