Microsoft KB Archive/95499

= FIX: Stack Fault May Occur If Trapping Divide By Zero =

Article ID: 95499

Article Last Modified on 10/29/2003

-

APPLIES TO


 * Microsoft Visual Basic 2.0 Standard Edition
 * Microsoft Visual Basic 3.0 Professional Edition

-



This article was previously published under Q95499



SYMPTOMS
When trapping a divide by zero or divide overflow error (error numbers 11 and 6 respectively) in a Visual Basic program, you may receive a stack fault if an MS-DOS session is also running. In this situation, the computer may also hang (stop responding) or automatically reboot.



CAUSE
This problem is caused by the Windows mathematics exception handling, not by Microsoft Visual Basic.



WORKAROUND
The only way to avoid this problem is to terminate all MS-DOS sessions before running a Visual Basic application that traps divide by zero or divide overflow errors.



STATUS
Microsoft has confirmed this to be a bug in Microsoft Windows version 3.1. This problem has been corrected in Visual Basic version 4.0.



Steps to Reproduce Problem
 Start an MS-DOS session in Windows. If the MS-DOS session appears full screen, press ALT+ENTER to make it a windowed session. Minimize the MS-DOS window. Start Visual Basic or from the File menu, choose New Project (ALT, F, N) if Visual Basic is already running. Form1 is created by default.  Add the following code to the Form_Click event procedure of Form1: Sub Form_Click On Error Resume Next Top: x% = DoEvents y% = 1 \ 0 'This will cause a division by zero error GoTo top End Sub

 From the Run menu, choose Start (ALT, R, S) or press the F5 key to run the program.</li> Click in the Form1 form. You may receive a stack fault here. if not, continue with step 7.</li> Double-click the minimized MS-DOS session icon to restore it.</li></ol>

You should receive the message &quot;VB caused a Stack Fault in module VB.EXE at 0001:0009.&quot;

Additional query words: buglist2.00 buglist3.00 fixlist4.00 2.00 3.00

Keywords: kbbug kbfix kbenv KB95499

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.