|
-
Aug 24th, 2006, 01:27 AM
#1
Thread Starter
Fanatic Member
[Resolved]FileCopy Wierdness...
VB Code:
Public Sub Install_Program(Optional Path_ As String, Optional EXEName_ As String, Optional Program_Name As String, Optional Company_ As String, Optional Replace_File_ As Boolean = True, Optional Debug_Mode As Boolean = False)
On Error Resume Next
Dim Drive_Let As String
Drive_Let = Find_Drive_Letter
DoEvents
MkDir Drive_Let & ":\Program Files\" & Company_
MkDir Drive_Let & ":\Program Files\" & Company_ & "\" & Program_Name
DoEvents
If Replace_File_ = True Then Kill Drive_Let & ":\Program Files\" & Company_ & "\" & Program_Name & "\" & EXEName_
DoEvents
[B]FileCopy FixPathFile(Path_, EXEName_), Drive_Let & ":\Program Files\" & Company_ & "\" & Program_Name & "\" & EXEName_[/B]
DoEvents
If Error <> 0 Then Debug.Print Err.Number, Err.Description, "Source: " & Err.Source
End Sub
When i try to compile the bolded line gives me this error:
"Compile Error"
"Expected Procedure not variable."
When i type up FileCopy the Popup text doesn't come up like it should.
Infact FileCopy doesn't work anywhere in the module, but if i copy this code & place it somewhere else, it works fine. I don't want to rearrange my entire program... does anyone know what could be causing this?
Last edited by Slyke; Aug 24th, 2006 at 03:00 AM.
-
Aug 24th, 2006, 01:35 AM
#2
Re: FileCopy Wierdness...
Where is the FixPathFile procedure located and what is its declaration (Public or Private, in a Module or Class or Form)?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Aug 24th, 2006, 01:38 AM
#3
Thread Starter
Fanatic Member
Re: FileCopy Wierdness...
VB Code:
Public Function FixPathFile(ByVal Path As String, File As String) As String
On Error Resume Next
If Right$(Path, 1) <> "\" Then
FixPathFile = Path & "\" & File
Else
FixPathFile = Path & File
End If
If Error <> 0 Then Debug.Print Err.Number, Err.Description, "Source: " & Err.Source
End Function
Same Module. But it still doesn't work even if FixPathFile is not in there.
-
Aug 24th, 2006, 01:50 AM
#4
Re: FileCopy Wierdness...
Are you using Option Explicit in that module? also, remove: On Error Resume Next, and run your code with CTRL-F5. Also, ensure VB is configured to "Break on all errors" and not "Break on Class module Errors".
Also, if you want those parameters to be Optional assign a default value to them, else remove optional, as they are always used inside the sub.
Last edited by jcis; Aug 24th, 2006 at 01:55 AM.
-
Aug 24th, 2006, 01:56 AM
#5
Thread Starter
Fanatic Member
Re: FileCopy Wierdness...
I've done that, tried with and without Option Explicit in that module. I removed On Error Resume Next and i set it to "Break on all errors" in the options. When i run that sub, no errors come up and no errors are reported in the Debug.Print screen.
I uncommented On Error Reume Next and saved it this way (so i won't forget later on).
VB Code:
Public Sub Install_Program(Optional Path_ As String = "", Optional EXEName_ As String = "", Optional Program_Name As String = "", Optional Company_ As String = "", Optional Replace_File_ As Boolean = True, Optional Debug_Mode As Boolean = False)
On Error Resume Next
Dim Drive_Let As String
Drive_Let = Find_Drive_Letter
If Path_ = "" Then Path_ = App.Path
If EXEName_ = "" Then EXEName_ = App.EXEName
If Program_Name = "" Then Program_Name = App.EXEName
If Company_ = "" Then Company_ = App.CompanyName
DoEvents
MkDir Drive_Let & ":\Program Files\" & Company_
MkDir Drive_Let & ":\Program Files\" & Company_ & "\" & Program_Name
DoEvents
If Replace_File_ = True Then Kill Drive_Let & ":\Program Files\" & Company_ & "\" & Program_Name & "\" & EXEName_
DoEvents
FileCopy FixPathFile(Path_, EXEName_), Drive_Let & ":\Program Files\" & Company_ & "\" & Program_Name & "\" & EXEName_
DoEvents
If Error <> 0 Then Debug.Print Err.Number, Err.Description, "Source: " & Err.Source
End Sub
Last edited by Slyke; Aug 24th, 2006 at 02:01 AM.
-
Aug 24th, 2006, 02:02 AM
#6
Re: FileCopy Wierdness...
Stop your code in the filecopy line, when it gets there, pause your code execution and paste this in the inmediate window (CTRL-G) to check the whole String thats being passed as parameter (? symbol included)
VB Code:
?FixPathFile(Path_, EXEName_), Drive_Let & ":\Program Files\" & Company_ & "\" & Program_Name & "\" & EXEName_
-
Aug 24th, 2006, 02:05 AM
#7
Re: FileCopy Wierdness...
You should not use Resume Next as a main error handler mechanism. 
You should switch back and add in an error handling procedure to got to.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Aug 24th, 2006, 02:10 AM
#8
Thread Starter
Fanatic Member
Re: FileCopy Wierdness...
It wouldn't allow that way, it came up with the same error as if i tried to compile it, instead i did this:
VB Code:
Debug.Print FixPathFile(Path_, EXEName_), Drive_Let & ":\Program Files\" & Company_ & "\" & Program_Name & "\" & EXEName_
Which gave the result:
"C:\Program Files\Microsoft Visual Studio\VB98\Screen Shooter\ScreenShooter c:\Program Files\MyCompany\MyProgram\ScreenShooter"
When ever this type of wierd error happens, it's usually another sub's fault, however all of the subs work fine. Which explains why this works in another module. I don't get why.
When i remove that & place it in another module, everything works fine and t compiles. There's nothing else called FileCopy either, so it is wierd.
-
Aug 24th, 2006, 02:44 AM
#9
Re: FileCopy Wierdness...
If Path_ is optional in Install_Program... why is it mandatory in FixFilePath????
That will not work....
-
Aug 24th, 2006, 02:48 AM
#10
Re: FileCopy Wierdness...
You overuse and use incorrectly On Error Resume Next. You willl have all kinds of problems...
-
Aug 24th, 2006, 02:50 AM
#11
Re: FileCopy Wierdness...
 Originally Posted by jcis
VB Code:
?FixPathFile(Path_, EXEName_), Drive_Let & "[SIZE=5][COLOR=Red]:[/COLOR][/SIZE]\Program Files\" & Company_ & "\" & Program_Name & "\" & EXEName_
You can't use a colon as part of a file name or path.
-
Aug 24th, 2006, 02:55 AM
#12
Re: FileCopy Wierdness...
schoolbusdriver,
Then how is it supposed to copy to the destination on a different drive?
-
Aug 24th, 2006, 02:59 AM
#13
Thread Starter
Fanatic Member
Re: FileCopy Wierdness...
Lol, well thanks for all the constructive critisism XD.
"If Path_ is optional in Install_Program... why is it mandatory in FixFilePath????"
If they don't enter a path in then it automatically goes to App.Path
Yeah, On error resume next is because this module is the same used for about 5 different programs. Usually it's perfect and the only error is when the file doesn't exist etc, which is why the Debug.Print is there. Any way i found the error.
There was a public FileCopy in const in another module and it was set to 0. For some reason it didn't show up when i searched the first time.
Thanks any ways... and sorry for all the confusion, lol. Lessoned learned: search and then research the search.
-
Aug 24th, 2006, 03:08 AM
#14
Re: FileCopy Wierdness...
 Originally Posted by randem
schoolbusdriver,
Then how is it supposed to copy to the destination on a different drive?
lol... missed that - I wasn't thinking of the root
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|