Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
1.33/5 (2 votes)
See more:
Hello guys

I created a programm with vb6 - everything works fine, except the exe file.

The exe-file crashs at this funtion:

HD_Settings_Save

'-----------------------------------------------------------

Global gcHDSettings As clsXCollection
 
Public Sub HD_Settings_Save()
On Error Resume Next
Dim i%
For i = 1 To gcHDSettings.Count
Me_Write gcHDSettings.Key(i)
Next
End Sub
 
Private Sub Me_Write(sType$)
On Error Resume Next
SaveSetting App.EXEName, "Settings", sType, gcHDSettings(sType)
End Sub

'-----------------------------------------------------------


I guess the following line
SaveSetting App.EXEName, "Settings", sType, gcHDSettings(sType)
causes the problem, but I still don't know exactly why :S


Thanks for any help.
Greetings v_tigra
Posted
Updated 17-Jun-14 3:07am
v3
Comments
Kornfeld Eliyahu Peter 16-Jun-14 3:20am    
You may check the event log for any message related to your exe...
v_tigra 16-Jun-14 4:18am    
How do I check them? I'm so confused with this problem :(
Kornfeld Eliyahu Peter 16-Jun-14 4:22am    
I see that you are using XP virtual machine, so read here - http://support.microsoft.com/kb/308427
(By the way VB6 works perfectly on Windows 7 too)
v_tigra 16-Jun-14 5:14am    
thank you, I'll read it
I suspect that you have some problems while creating the exe or setup.

The variable "gcHDSettings" was not initialized..
Following code has been missing:
Set gcHDSettings = New clsXCollection


Greetings
v_tigra
 
Share this answer
 
Comments
CHill60 17-Jun-14 12:35pm    
That would have been far easier to find had you not used On Error Resume Next - funnily enough you would have been shown an error message with a good indication of the problem. Avoid using On Error Resume Next unless you are going to check the error number and do something with it *immediately* after a line that might cause problems. Even then it's a bad idea.
v_tigra 18-Jun-14 8:29am    
okay, thanks
Create a log file, in that write log for every line of code then easily find the line where the exe file closes.
 
Share this answer
 
Comments
v_tigra 17-Jun-14 8:56am    
The exe-file crashs at this funtion:

HD_Settings_Save

---------------------------------------------------------------------------------------
Global gcHDSettings As clsXCollection

Public Sub HD_Settings_Save()
On Error Resume Next
Dim i%
For i = 1 To gcHDSettings.Count
Me_Write gcHDSettings.Key(i)
Next
End Sub

Private Sub Me_Write(sType$)
On Error Resume Next
SaveSetting App.EXEName, "Settings", sType, gcHDSettings(sType)
End Sub
---------------------------------------------------------------------------------------

I guess the following line

SaveSetting App.EXEName, "Settings", sType, gcHDSettings(sType)

causes the problem, but I still don't know exactly why :S
Mike Meinz 17-Jun-14 9:33am    
What do you mean by "crash"? Is there an error message?

If you run the program in Debug mode within Visual Studio, the exact line that causes the error will be displayed and you can use the Immediate window to look at your variables.
v_tigra 17-Jun-14 9:38am    
no, there is no error message. It just doesn't run. I made a few exe-files and testet each file. If I write the funtion "HD_Settings_Save" as a comment (with ') and make an exe-file, everything works fine, the exe-file runs without problems. But if I write the function "HD_Settings_Save" as a normal code line and then make an exe-file, it doens't run, no error-message is shown. The only thing I see is the process in the task-manager.

Everytime when I run the programm in debug mode in visual studio, no error-message is shown and everything works fine even when I put this line in as a normal code - no error message.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900