Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Problems with VB6
Hello,

I am not sure where to post this, but I will try here first, alhough this
may be a Widows problem.

I am having problems with VB6SP5 acting up lately. Sometimes it opens veeery
slooowly, then sometimes it freezes.
Today I reinstalled it for the second time in about a w. I had seen this
problem before, but rebooting usually fixed it. I also reapplied SP5 this
time and so far it seems to work OK, except for one thing that may not be VB
related.

I am working on an application which uses a FileSystemObject to copy an
Excel workbook file. The past few days this operation has caused error # 3,
(last dll error).

I am running Widows 2000 Pro with all the lates updates running behind a
hardware firewall.
I have recently upgraded Norton Internet Security, but I think I have set it
up correctly and I have recently done a full scan, so I doubt it is caused
by a virus.

Other VB apps seems to run OK.

Any ideas would be appreciated.

Ragnar



Report this thread to moderator Post Follow-up to this message
Old Post
Ragnar Midtskogen
10-27-04 08:55 AM


Re: Problems with VB6
VB6 on Win 2000 should scream! Try shutting down Norton and disabling all
Norton services, ensuring you delete the registry keys under the Run key
(you can export the key, then delete it, so you can re-add it back). Then
reboot and see if VB behaves. Disconnect the network if you're concerned
about a virus with Norton shut down.

Generally reinstalling VB is never necessary ... in fact, since using VB3 I
can not remember one instance where I had to reinstall VB to resolve a
problem. Usually some other external force - software, network, bad drives -
are at work.

--


Randy Birch
MS MVP Visual Basic
http://vbnet.mvps.org/


"Ragnar Midtskogen" <ragnar_ng@newsgroups.com> wrote in message
news:%237jrDe8uEHA.452@TK2MSFTNGP09.phx.gbl...
: Hello,
:
: I am not sure where to post this, but I will try here first, alhough this
: may be a Widows problem.
:
: I am having problems with VB6SP5 acting up lately. Sometimes it opens
veeery
: slooowly, then sometimes it freezes.
: Today I reinstalled it for the second time in about a w. I had seen
this
: problem before, but rebooting usually fixed it. I also reapplied SP5 this
: time and so far it seems to work OK, except for one thing that may not be
VB
: related.
:
: I am working on an application which uses a FileSystemObject to copy an
: Excel workbook file. The past few days this operation has caused error #
3,
: (last dll error).
:
: I am running Widows 2000 Pro with all the lates updates running behind a
: hardware firewall.
: I have recently upgraded Norton Internet Security, but I think I have set
it
: up correctly and I have recently done a full scan, so I doubt it is caused
: by a virus.
:
: Other VB apps seems to run OK.
:
: Any ideas would be appreciated.
:
: Ragnar
:
:


Report this thread to moderator Post Follow-up to this message
Old Post
Randy Birch
10-27-04 08:55 AM


Re: Problems with VB6
just a thought - if you have the excel file open - may be causing problems

"Ragnar Midtskogen" <ragnar_ng@newsgroups.com> wrote in message
news:%237jrDe8uEHA.452@TK2MSFTNGP09.phx.gbl...
> Hello,
>
> I am not sure where to post this, but I will try here first, alhough this
> may be a Widows problem.
>
> I am having problems with VB6SP5 acting up lately. Sometimes it opens
veeery
> slooowly, then sometimes it freezes.
> Today I reinstalled it for the second time in about a w. I had seen
this
> problem before, but rebooting usually fixed it. I also reapplied SP5 this
> time and so far it seems to work OK, except for one thing that may not be
VB
> related.
>
> I am working on an application which uses a FileSystemObject to copy an
> Excel workbook file. The past few days this operation has caused error #
3,
> (last dll error).
>
> I am running Widows 2000 Pro with all the lates updates running behind a
> hardware firewall.
> I have recently upgraded Norton Internet Security, but I think I have set
it
> up correctly and I have recently done a full scan, so I doubt it is caused
> by a virus.
>
> Other VB apps seems to run OK.
>
> Any ideas would be appreciated.
>
> Ragnar
>
>


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.781 / Virus Database: 527 - Release Date: 10/21/2004



Report this thread to moderator Post Follow-up to this message
Old Post
Hal Rosser
10-27-04 08:55 AM


Re: Problems with VB6
Thank you Randy!

I will try your suggestion when I am through with this update, the client is
determined to roll out the app next w, so time is short right now.
Everything appears to run fine on my laptop, so I am not dead in the water,
but my laptop is not as fast.

After reinstalling VB and reapplying SP5 VB opens quickly and several other
applications, some very complex, appears to run OK.
The problem right now is in the code below:
I check if mvarSourceFile exists, then tries to copy it by using CopyFile.
The file is an Excel workbook file.
This used to work on both my computers, it still works on my laptop.
On my desktop the CopyFile call returns a nonzero value and the LastDllError
is 3. I think 6 is denied access, I have not been able to find out what 3
means.
Do you think that could be a Norton problem, or a Win 2000 problem?

Ragnar

----------------------------------------------------------------------------
--------------------------
mvarSourceFolder,  mvarSourceFile and sLogMsg are declared as strings, oFSO
is a filesystemobject

CopyFile is declared as
Public Declare Function CopyFile& _
Lib "kernel32" _
Alias "CopyFileA" _
(ByVal lpExistingFileName As String, _
ByVal lpNewFileName As String, _
ByVal bFailIfExists As Long)

' Make a copy of the source file,
If oFSO.FileExists(mvarSourceFolder & "\" & mvarSourceFile) Then
If  (CopyFile(lpExistingFileName:=mvarSource
Folder & "\" &
mvarSourceFile, _
lpNewFileName:=mvarTargetFolder & "\" & mvarTemplateFileName,
_
bFailIfExists:=0) <> 0) Then
' Write progress message to log
file --------------------------------
'lnFileSize = FileLen(PathName:=mvarTargetFolder & "\" &
mvarTemplateFileName)
sLogMsg = CStr(Now) & " | Created 'Template' file " _
& mvarTargetFolder & "\" & mvarTemplateFileName
tsLogfile.WriteLine (sLogMsg)
Else
' Handle the error
lnDLLError = Err.LastDllError
sLogMsg = "CopyFile returned error # " _
& Str(lnDLLError) & " creating 'Template' file"
tsLogfile.WriteLine (sLogMsg)
SplitWorkBook = "ERROR"
GoTo Exit_SplitWorkBook
End If



Report this thread to moderator Post Follow-up to this message
Old Post
Ragnar Midtskogen
10-27-04 08:55 PM


Re: Problems with VB6
Thank you Hal, unfortunately the file is not open. I get this problem right
after starting the machine.

Ragnar



Report this thread to moderator Post Follow-up to this message
Old Post
Ragnar Midtskogen
10-27-04 08:55 PM


Re: Problems with VB6
error 3 = "The system cannot find the path specified."

Make sure neither mvarSourceFolder and mvarTargetFolder point to a disk
root. These contain the trailing slash, so your adding "\" is unneeded and
will cause an error if the result is c:\\somefolder.

You might want to use this in place of your hard-concatenation of the slash
...

Private Function QualifyPath(sPath As String) As String

If Len(sPath) > 0 Then

If Right$(sPath, 1) <> "\" Then
QualifyPath = sPath & "\"
Else
QualifyPath = sPath
End If
Else
QualifyPath = ""
End If

End Function

... then just call as:

oFSO. FileExists(QualifyPath(mvarSourceFolder)
& mvarSourceFile)

You may also want to look at
http://vbnet.mvps.org/code/fileapi/copyfile.htm, which does essentially the
same thing as your code, without the filesystemobject.
-- Randy BirchMS MVP Visual Basichttp://vbnet.mvps.org/

"Ragnar Midtskogen" <ragnar_ng@newsgroups.com> wrote in message
news:urgjAoEvEHA.944@TK2MSFTNGP11.phx.gbl...
: Thank you Randy!
:
: I will try your suggestion when I am through with this update, the client
is
: determined to roll out the app next w, so time is short right now.
: Everything appears to run fine on my laptop, so I am not dead in the
water,
: but my laptop is not as fast.
:
: After reinstalling VB and reapplying SP5 VB opens quickly and several
other
: applications, some very complex, appears to run OK.
: The problem right now is in the code below:
: I check if mvarSourceFile exists, then tries to copy it by using CopyFile.
: The file is an Excel workbook file.
: This used to work on both my computers, it still works on my laptop.
: On my desktop the CopyFile call returns a nonzero value and the
LastDllError
: is 3. I think 6 is denied access, I have not been able to find out what 3
: means.
: Do you think that could be a Norton problem, or a Win 2000 problem?
:
: Ragnar
:
: --------------------------------------------------------------------------
----------------------------
: mvarSourceFolder,  mvarSourceFile and sLogMsg are declared as strings,
oFSO
: is a filesystemobject
:
: CopyFile is declared as
: Public Declare Function CopyFile& _
:                         Lib "kernel32" _
:                         Alias "CopyFileA" _
:                         (ByVal lpExistingFileName As String, _
:                         ByVal lpNewFileName As String, _
:                         ByVal bFailIfExists As Long)
:
: ' Make a copy of the source file,
:    If oFSO.FileExists(mvarSourceFolder & "\" & mvarSourceFile) Then
:       If  (CopyFile(lpExistingFileName:=mvarSource
Folder & "\" &
: mvarSourceFile, _
:                lpNewFileName:=mvarTargetFolder & "\" &
mvarTemplateFileName,
: _
:                                           bFailIfExists:=0) <> 0) Then
:          ' Write progress message to log
: file --------------------------------
:          'lnFileSize = FileLen(PathName:=mvarTargetFolder & "\" &
: mvarTemplateFileName)
:          sLogMsg = CStr(Now) & " | Created 'Template' file " _
:                   & mvarTargetFolder & "\" & mvarTemplateFileName
:          tsLogfile.WriteLine (sLogMsg)
:       Else
:          ' Handle the error
:          lnDLLError = Err.LastDllError
:          sLogMsg = "CopyFile returned error # " _
:             & Str(lnDLLError) & " creating 'Template' file"
:          tsLogfile.WriteLine (sLogMsg)
:          SplitWorkBook = "ERROR"
:          GoTo Exit_SplitWorkBook
:       End If
:
:


Report this thread to moderator Post Follow-up to this message
Old Post
Randy Birch
10-28-04 01:55 AM


Re: Problems with VB6
Thank you Randy,

> Make sure neither mvarSourceFolder and mvarTargetFolder point to a disk
> root. These contain the trailing slash, so your adding "\" is unneeded and
> will cause an error if the result is c:\\somefolder.

The error is returned by CopyFile, not the FileSystemObject. I included that
line in the snippet just to show that the fully qualified filespec would be
valid. I have stepped through the code to pinpoint where the error occurs.

The path is normally browsed to by using the SHBrowseForFolder API call
(Shell32), in which case there is no chance of getting an invalid path. But,
in case the user types in the path, I check it.
The file name is also browsed to and selected, by using the CommonDialog
object's FileOpen dialog, and again, I use an FSO.to verify that the file
does exist, just in case the user types it in.

This code used to work and it still works on my laptop (Win XP Pro) as well
as my desktop at the office (Win 2K Pro), as well as several machines at my
client's, using exactly the same code. The only place it does not work is my
desktop at my home office (Win2K Pro).

My conclusion is that there is something wrong with Windows on my home
desktop, so I will either try to repair it, or maybe go to XP.
But I will try disabling Norton, just to see, although it seem far fetched
that it would cause CopyFile to fail, since it is part of the kernel.

Ragnar

On that machine I have even stepped through the code, verifying that the
path and file name are correct
"Randy Birch" <rgb_removethis@mvps.org> wrote in message
news:eAcDPOIvEHA.2564@TK2MSFTNGP12.phx.gbl...
> error 3 = "The system cannot find the path specified."
>
> Make sure neither mvarSourceFolder and mvarTargetFolder point to a disk
> root. These contain the trailing slash, so your adding "\" is unneeded and
> will cause an error if the result is c:\\somefolder.
>
> You might want to use this in place of your hard-concatenation of the
> slash
> ...
>
> Private Function QualifyPath(sPath As String) As String
>
>   If Len(sPath) > 0 Then
>
>      If Right$(sPath, 1) <> "\" Then
>         QualifyPath = sPath & "\"
>      Else
>         QualifyPath = sPath
>      End If
>   Else
>      QualifyPath = ""
>   End If
>
> End Function
>
> ... then just call as:
>
> oFSO. FileExists(QualifyPath(mvarSourceFolder)
& mvarSourceFile)
>
> You may also want to look at
> http://vbnet.mvps.org/code/fileapi/copyfile.htm, which does essentially
> the
> same thing as your code, without the filesystemobject.
> -- Randy BirchMS MVP Visual Basichttp://vbnet.mvps.org/
>
> "Ragnar Midtskogen" <ragnar_ng@newsgroups.com> wrote in message
> news:urgjAoEvEHA.944@TK2MSFTNGP11.phx.gbl...
> : Thank you Randy!
> :
> : I will try your suggestion when I am through with this update, the
> client
> is
> : determined to roll out the app next w, so time is short right now.
> : Everything appears to run fine on my laptop, so I am not dead in the
> water,
> : but my laptop is not as fast.
> :
> : After reinstalling VB and reapplying SP5 VB opens quickly and several
> other
> : applications, some very complex, appears to run OK.
> : The problem right now is in the code below:
> : I check if mvarSourceFile exists, then tries to copy it by using
> CopyFile.
> : The file is an Excel workbook file.
> : This used to work on both my computers, it still works on my laptop.
> : On my desktop the CopyFile call returns a nonzero value and the
> LastDllError
> : is 3. I think 6 is denied access, I have not been able to find out what
> 3
> : means.
> : Do you think that could be a Norton problem, or a Win 2000 problem?
> :
> : Ragnar
> :
> : ------------------------------------------------------------------------
--
> ----------------------------
> : mvarSourceFolder,  mvarSourceFile and sLogMsg are declared as strings,
> oFSO
> : is a filesystemobject
> :
> : CopyFile is declared as
> : Public Declare Function CopyFile& _
> :                         Lib "kernel32" _
> :                         Alias "CopyFileA" _
> :                         (ByVal lpExistingFileName As String, _
> :                         ByVal lpNewFileName As String, _
> :                         ByVal bFailIfExists As Long)
> :
> : ' Make a copy of the source file,
> :    If oFSO.FileExists(mvarSourceFolder & "\" & mvarSourceFile) Then
> :       If  (CopyFile(lpExistingFileName:=mvarSource
Folder & "\" &
> : mvarSourceFile, _
> :                lpNewFileName:=mvarTargetFolder & "\" &
> mvarTemplateFileName,
> : _
> :                                           bFailIfExists:=0) <> 0) Then
> :          ' Write progress message to log
> : file --------------------------------
> :          'lnFileSize = FileLen(PathName:=mvarTargetFolder & "\" &
> : mvarTemplateFileName)
> :          sLogMsg = CStr(Now) & " | Created 'Template' file " _
> :                   & mvarTargetFolder & "\" & mvarTemplateFileName
> :          tsLogfile.WriteLine (sLogMsg)
> :       Else
> :          ' Handle the error
> :          lnDLLError = Err.LastDllError
> :          sLogMsg = "CopyFile returned error # " _
> :             & Str(lnDLLError) & " creating 'Template' file"
> :          tsLogfile.WriteLine (sLogMsg)
> :          SplitWorkBook = "ERROR"
> :          GoTo Exit_SplitWorkBook
> :       End If
> :
> :
>



Report this thread to moderator Post Follow-up to this message
Old Post
Ragnar Midtskogen
10-29-04 01:55 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Visual Basic archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 04:57 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.