Click here to Skip to main content
15,887,434 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: VS 2005 VB.NET: Global Module failing to initializ Pin
Dave Kreskowiak17-Apr-08 8:18
mveDave Kreskowiak17-Apr-08 8:18 
GeneralRe: VS 2005 VB.NET: Global Module failing to initializ Pin
kindman_nb17-Apr-08 13:48
kindman_nb17-Apr-08 13:48 
GeneralRe: VS 2005 VB.NET: Global Module failing to initializ Pin
Dave Kreskowiak18-Apr-08 3:57
mveDave Kreskowiak18-Apr-08 3:57 
GeneralCompare values in DataRow field with its original value Pin
Steven J Jowett17-Apr-08 6:28
Steven J Jowett17-Apr-08 6:28 
GeneralRe: Compare values in DataRow field with its original value Pin
Dave Kreskowiak17-Apr-08 8:15
mveDave Kreskowiak17-Apr-08 8:15 
GeneralRe: Compare values in DataRow field with its original value Pin
Steven J Jowett17-Apr-08 11:19
Steven J Jowett17-Apr-08 11:19 
GeneralRe: Compare values in DataRow field with its original value Pin
Dave Kreskowiak18-Apr-08 1:32
mveDave Kreskowiak18-Apr-08 1:32 
GeneralOT: DeleteFile and MoveFile in VBS Pin
stephan_00717-Apr-08 5:22
stephan_00717-Apr-08 5:22 
hy everyone!

i know my question is of topic but maybe someone has an idea why this problem occures:

I do have a macro which parses files. when finished i want to move the file to a different directory (either the one, where well parsed files are put into or in the one where bad parsed files are put into).

therefor i have to use the movefile and deletefile.

because my macro first checks, if there is already and (old) copy of the file, if so then delete it and replace it with the new one. if not then i simply copy it to the destination file.

therefor i programmed

Function DeleteandMoveFile(ByVal dest As String, ByVal source As String, ByVal filename As String) As Boolean
Dim filesys As Object
DeleteandMoveFile = TRUE 'just a dummy operation

  Set filesys = CreateObject("Scripting.FileSystemObject")

  'Check if File exists in destinationpath then delete it
  If filesys.FileExists(dest & filename) Then
    If filesys.DeleteFile(dest & filename)then
      'MsgBox "file deleted successfully
    Else
      'MsgBox "couldn't delete file"
      Application.WriteEventLog "macro", "couldn't delete file",5
    End If		
  End If

  ' Check if file exists in source path then move it
  If filesys.FileExists(source & filename) Then 
    If filesys.MoveFile(source & filename, dest)
      'MsgBox "file moved"
    Else		
      Application.WriteEventLog "macro", "file couldn't be moved!",5
    End If
  Else
    Application.WriteEventLog "macro", "file does not exist!" ,5
  End If
  Set filesys = Nothing
End Function


Looks fine, doesn't it? Well the macro does exactly what I want it to, but it also writes the error messages into eventlog. Meaning it does the if statements but the steps directly to the error message and continues operating. As if I also added the error message to the if statement.

Does anyone of you have an idea? Does Windows somehow have a handle or something on the file which causes an exception when moving or deleting??

If it doesn't work, then it would be "ok" for me, but remember: The macro does what I want it to but throws the error messages as well (seems to be in if and else during the same loop!).

Maybe anyone of you could help me please!

thanks.
Stephan.
GeneralRe: OT: DeleteFile and MoveFile in VBS Pin
Dave Kreskowiak17-Apr-08 6:51
mveDave Kreskowiak17-Apr-08 6:51 
GeneralRe: OT: DeleteFile and MoveFile in VBS Pin
stephan_00717-Apr-08 8:24
stephan_00717-Apr-08 8:24 
GeneralRe: OT: DeleteFile and MoveFile in VBS Pin
Dave Kreskowiak17-Apr-08 8:37
mveDave Kreskowiak17-Apr-08 8:37 
GeneralRe: OT: DeleteFile and MoveFile in VBS Pin
stephan_00717-Apr-08 8:42
stephan_00717-Apr-08 8:42 
GeneralRe: OT: DeleteFile and MoveFile in VBS Pin
Ashfield17-Apr-08 9:00
Ashfield17-Apr-08 9:00 
GeneralRe: OT: DeleteFile and MoveFile in VBS Pin
stephan_00717-Apr-08 9:31
stephan_00717-Apr-08 9:31 
General"Can not create ActiveX Component" Pin
Harold_Wishes17-Apr-08 5:07
Harold_Wishes17-Apr-08 5:07 
GeneralRe: "Can not create ActiveX Component" Pin
Dave Kreskowiak17-Apr-08 5:11
mveDave Kreskowiak17-Apr-08 5:11 
GeneralRe: "Can not create ActiveX Component" Pin
Harold_Wishes17-Apr-08 5:22
Harold_Wishes17-Apr-08 5:22 
GeneralDatagrid Colour Based on the Records in the table Pin
Vimalsoft(Pty) Ltd17-Apr-08 3:29
professionalVimalsoft(Pty) Ltd17-Apr-08 3:29 
GeneralRe: Datagrid Colour Based on the Records in the table Pin
Dave Kreskowiak17-Apr-08 3:42
mveDave Kreskowiak17-Apr-08 3:42 
GeneralDatabase connection using Vb.net 2003 and MySQL 4.1 Pin
magesh2117-Apr-08 2:27
magesh2117-Apr-08 2:27 
GeneralRe: Database connection using Vb.net 2003 and MySQL 4.1 Pin
Dave Kreskowiak17-Apr-08 3:34
mveDave Kreskowiak17-Apr-08 3:34 
Generalcombo box invalid property array index Pin
kankeyan17-Apr-08 0:20
kankeyan17-Apr-08 0:20 
GeneralRe: combo box invalid property array index Pin
Luc Pattyn17-Apr-08 0:37
sitebuilderLuc Pattyn17-Apr-08 0:37 
GeneralRe: combo box invalid property array index Pin
kankeyan17-Apr-08 2:18
kankeyan17-Apr-08 2:18 
GeneralRe: combo box invalid property array index Pin
Luc Pattyn17-Apr-08 2:46
sitebuilderLuc Pattyn17-Apr-08 2:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.