6

Create a new VB6 project. Paste the code below as your project code. Hit Run. See if it crashes... Remove or simplify anything you like in this code, and then it will work fine. Can anyone please shed some light on why this is crashing?

This has been tested on eight PC's so far, all running various combinations of Windows XP, Windows Vista, Windows 7, Office 2010, and Office 2007. The ones where it was tested in the Visual Basic IDE have Visual Basic 6 SP 6 installed.

Private Sub Sleep(ByVal nSeconds As Long)
    Dim nStart As Long: nStart = Timer
    Do
        DoEvents
    Loop Until (Timer - nStart) >= nSeconds
End Sub

Private Sub Crash()
    Dim sTempPath As String: sTempPath = Space(255)
End Sub

Private Sub Form_Initialize()
    Sleep 1
    Crash
End Sub


Addendum #1:

I put this as a macro in Excel 2010, replacing Form_Initialize() with Workbook_Open(), and sure enough, when you open the document. It crashes!

Addendum #2:

I added break points to every line before hitting "Run" and it crashed before it got to the first break point. But again, if I simplify or remove anything in this, it works fine and does not crash.

Addendum #3:

Tried MicSim's suggestion of removing the colon, and it did not crash. Added it back, ran it again and it did not crash. Closed Visual Basic, and put in the original code and it crashed.

Addendum #4:

Problem Details from Visual Basic 6 IDE:

Problem signature:
Problem Event Name: APPCRASH
Application Name: VB6.EXE
Application Version: 6.0.81.76
Application Timestamp: 3592011f
Fault Module Name: VBA6.dll
Fault Module Version: 6.0.0.8169
Fault Module Timestamp: 358b0c74
Exception Code: c0000005
Exception Offset: 00026329
OS Version: 6.1.7601.2.1.0.256.4
Locale ID: 1033
Additional Information 1: 7e3b
Additional Information 2: 7e3beb1e9ccf6d519c5b994ca59a280f
Additional Information 3: 7b83
Additional Information 4: 7b833c57ebcf54809fd3aaccd8ea4f46

Read our privacy statement online:
http://go.microsoft.com/fwlink/?linkid=104288&clcid=0x0409

If the online privacy statement is not available, please read our privacy statement offline:
C:\Windows\system32\en-US\erofflps.txt

Addendum #5:

Problem Details from Microsoft Excel 2010:

Problem signature:
Problem Event Name: APPCRASH
Application Name: EXCEL.EXE
Application Version: 14.0.4756.1000
Application Timestamp: 4b9c08e8
Fault Module Name: VBE7.DLL
Fault Module Version: 7.0.15.90
Fault Module Timestamp: 4b7b1248
Exception Code: c0000005
Exception Offset: 00045b6a
OS Version: 6.1.7601.2.1.0.256.4
Locale ID: 1033

Additional information about the problem:
LCID: 1033
skulcid: 1033

Read our privacy statement online:
http://go.microsoft.com/fwlink/?linkid=104288&clcid=0x0409

If the online privacy statement is not available, please read our privacy statement offline:
C:\Windows\system32\en-US\erofflps.txt

Screenshot after hitting Run, or Build

Drew Chapin
  • 7,779
  • 5
  • 58
  • 84
  • 3
    No crash for me on VB6 SP6, Win 7 x64 SP1. – MicSim Dec 13 '11 at 16:20
  • lol, I can't even hit "Build" without it crashing on 32 bit. – Drew Chapin Dec 13 '11 at 16:24
  • 1
    Works on my VB6 SP6. 32-bit XP SP3 machine. – Jay Riggs Dec 13 '11 at 16:39
  • WFM with VB6 sp6 on Win7 32-bit – Deanna Dec 13 '11 at 16:39
  • No offence meant but voted to close as it's not really a suitable question for SO. – Deanna Dec 13 '11 at 16:41
  • When you guys are saying it worked for you, are you saying the crash occurred, or did not occur? – Drew Chapin Dec 13 '11 at 16:41
  • I don't understand what's going on here. I've tested this on six computers at work, and it's crashed on every one of them. I don't think it's anything specific to our environment because the one I originally discovered this on is not on the domain, and is as close to a home development computer as you could get. – Drew Chapin Dec 13 '11 at 17:01
  • 1
    Can you tell which line it's 'crashing' on? Set a breakpoint at the beginning of your Sleep and Crash procedures and step through and tell us what problem you see and on which line. – Jay Riggs Dec 13 '11 at 17:06
  • 1
    Tried your suggestion with Excel 2010 and it's crashing. It's because of the colon (:) after the Long and String. Remove it and make 2 lines and it's ok. Making 2 lines but leaving colon there still leads to crash. Can't tell you why. – MicSim Dec 13 '11 at 17:12
  • No crash for me: WinXP, VB6 SP5 (yes I know). **Exactly what do you mean by "crash"?** Does the VB6 IDE immediately exits with no error message? Or does an error message appear? Or what? – MarkJ Dec 13 '11 at 17:26
  • @MarkJ, I added a screen shot for clarification. – Drew Chapin Dec 13 '11 at 17:31
  • Is this something you need to make work, or is this just some academic exercise? – jac Dec 13 '11 at 21:39
  • @Beaner, This began from a much more complex piece of code that involes custom DLL calls, and Windows API calls, and that I need for a project at work. So, yes it needs to work. I spent two days thinking I had something wrong in my custom DLL and today, I started removing line by line until eventually I was left with what you see here. McSim figured out it had something to do with the colons on the variable asignments, and I now have it working. But this has become a much bigger issues as there is nothing here that should cause this crash. So, the question is... why does this crash? – Drew Chapin Dec 14 '11 at 00:30
  • I believe it is in fact the compiler for Visual Basic that is causing the crash. As I said in my post, I can't build the exe without crashing the IDE. – Drew Chapin Dec 14 '11 at 00:31
  • Could you click on the "View Problem Details" button and paste the full crash log? – Gabriel Dec 14 '11 at 01:25
  • @Gabriel, Yes, but I will have to wait until I go back to work tomorrow. – Drew Chapin Dec 14 '11 at 01:30
  • How could people upvote a comment that says "Works for me on VB6 SP6 ... " ? – CJ7 Dec 14 '11 at 08:40
  • 1
    @druciferre: now that you have a solution, don't worry about why it doesn't work. Move on to more important things. Don't waste time speculating on why some Microsoft product doesn't work. All products can have bugs, including IDEs and compilers. – CJ7 Dec 14 '11 at 08:43

1 Answers1

5

After reviewing your question and all the addendums, I realized that your computer is running the release version of VB6, and not SP6.

Your crash details indicate the following versions:

  • VB6.exe: 6.0.81.76
  • VBA6.dll: 6.0.0.8179

The exact build numbers of Visual Basic 6.0 SP6 files are as follows:

  • VB6.exe: 6.0.97.82
  • VBA6.dll: 6.0.0.9782

Exception code c0000005 corresponds to an access violation in module vba6.dll. A similar problem is documented on Microsoft KB

I have not found an accurate source listing build numbers for each VB6 service packs, but it looks like this is the RTM version. Even though you might have installed SP6 yourself, a rogue installer may have overwritten shared system files by an older version after the service pack was installed. This would explain why a lot of users commented that the code is working fine for them with a seemingly similar setup.

Gabriel
  • 3,733
  • 16
  • 29
  • So, obviously, the compiler is failing because it is improperly installed. – Motomotes Jan 04 '12 at 03:54
  • I'm not so sure this is the problem, as I said this also occurs in Microsoft Excel 2010 as well which is using VB7.dll (version 7.0.15.90). – Drew Chapin Jan 04 '12 at 19:17
  • Try reinstalling VB6 and updating to SP6 and see if that fixes the problem. It won't explain the Excel part but at least you can confirm or reject that in VB6 with SP6 it is fixed. – Shane Wealti Jan 04 '12 at 21:37