VB6 Timer (), Space () Form_Initialize () causes an immediate crash

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

This has been tested on eight computers so far, all of which have been run in various combinations of Windows XP, Windows Vista, Windows 7, Office 2010 and Office 2007. Those in which it was tested in Visual Basic have Visual Basic 6 SP 6.

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, of course, when opening the document. It will work!

Addendum # 2:

I added breakpoints to each line before clicking Run, and it crashed before I hit the first breakpoint. But then again, if I simplify or delete anything in this, it works fine and doesn't crash.

Addendum # 3:

I tried MicSim's colon removal suggestion and it didn't crash. Added it back, started again, and it did not crash. Closed Visual Basic, and pasted the source code, and it crashed.

Addendum 4:

Problem Details from the Visual Basic 6 IDE:

Task signature:
Problem Event Name: APPCRASH
Application Name: VB6.EXE
Application Version: 6.0.81.76
Application Timestamp: 3592011f
Fault Module Name: VBA6.dll
Module Error Version: 6.0.0.8169
Fault Module Timestamp: 358b0c74
Exception Code: c0000005
Offset 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 an online privacy statement is not available, check out our offline privacy statement:
C: \ Windows \ system32 \ EN-US \ erofflps.txt

Addendum # 5:

Details of the problem 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
Module Error Version: 7.0.15.90
Error Timestamp: 4b7b1248
Exception Code: c0000005
Displacement 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 an online privacy statement is not available, check out our offline privacy statement:
C: \ Windows \ system32 \ EN-US \ erofflps.txt

Screenshot after hitting Run, or Build

+6
source share
1 answer

After looking at your question and all the additions, I realized that the version of VB6 and not SP6 is installed on your computer.

The following versions indicate your crash data:

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

The exact assembly numbers for Visual Basic 6.0 SP6 files are as follows:

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

The exception code c0000005 corresponds to an access violation in the vba6.dll module. A similar problem is described in Microsoft KB.

I did not find the exact source list assembly numbers for each VB6 service pack, but it looks like this is a version of RTM . Even if you may have installed SP6 yourself, the rogue installer may overwrite shared system files with an older version after installing the service pack. This explains why many users commented that the code works fine for them with a seemingly similar setting.

+5
source

Source: https://habr.com/ru/post/903696/


All Articles