Microsoft KB Archive/150229: Difference between revisions

From BetaArchive Wiki
(importing KB archive)
 
m (Text replacement - """ to """)
 
Line 56: Line 56:
                 </pre>
                 </pre>
This problem can be avoided by using:
This problem can be avoided by using:
<pre class="codesample">  If Text1.Text = &quot;&quot; Then
<pre class="codesample">  If Text1.Text = "" Then
       Grid1.Clip = &quot;&quot;
       Grid1.Clip = ""
   Else
   Else
       Grid1.Clip = Text1.Text
       Grid1.Clip = Text1.Text
Line 81: Line 81:
<li>Place a Grid Control on Form1.</li>
<li>Place a Grid Control on Form1.</li>
<li>Place a Command button and a Text box on Form1.</li>
<li>Place a Command button and a Text box on Form1.</li>
<li>Click the Property window for the Text box and delete the Text property (delete &quot;Text1&quot;).</li>
<li>Click the Property window for the Text box and delete the Text property (delete "Text1").</li>
<li><p>In the Click event of the Command button, place the following code:</p>
<li><p>In the Click event of the Command button, place the following code:</p>
<pre class="codesample">  Private Sub Command1_Click()
<pre class="codesample">  Private Sub Command1_Click()
Line 90: Line 90:
<div class="errormessage">
<div class="errormessage">


&quot;VB caused a General Protection Fault in module GRID16.OCX at 0001:752D&quot;
"VB caused a General Protection Fault in module GRID16.OCX at 0001:752D"


</div></li></ol>
</div></li></ol>
Line 96: Line 96:
To work around this problem, change the code in the Click event of the button to:
To work around this problem, change the code in the Click event of the button to:
<pre class="codesample">  Private Sub Command1_Click()
<pre class="codesample">  Private Sub Command1_Click()
       If Text1.Text = &quot;&quot; Then
       If Text1.Text = "" Then
         Grid1.Clip = &quot;&quot;
         Grid1.Clip = ""
       Else
       Else
         Grid1.Clip = Text1.Text
         Grid1.Clip = Text1.Text

Latest revision as of 10:10, 21 July 2020

Article ID: 150229

Article Last Modified on 1/9/2003



APPLIES TO

  • Microsoft Visual Basic 4.0 Professional Edition
  • Microsoft Visual Basic 4.0 16-bit Enterprise Edition



This article was previously published under Q150229

SYMPTOMS

If the Clip property of the Grid control is set equal to the Text property of an empty Text box, a General Protection Fault occurs.

RESOLUTION

The Clip property can be explicitly set to an empty string. If the Text box is empty, set the Clip property of the Grid control to an empty string. If the Text box is not empty, set the Clip property to the Text property. For example, instead of:

   Grid1.Clip = Text1.Text
                

This problem can be avoided by using:

   If Text1.Text = "" Then
       Grid1.Clip = ""
   Else
       Grid1.Clip = Text1.Text
   EndIf
                

STATUS

Microsoft has confirmed this to be an issue in the Microsoft products listed at the beginning of this article.

MORE INFORMATION

Steps to Reproduce Problem

  1. Start a new project in Visual Basic. Form1 is created by default.
  2. Place a Grid Control on Form1.
  3. Place a Command button and a Text box on Form1.
  4. Click the Property window for the Text box and delete the Text property (delete "Text1").
  5. In the Click event of the Command button, place the following code:

       Private Sub Command1_Click()
          Grid1.Clip = Text1.Text
       End Sub
                            
  6. Run the project by pressing F5. When running this code under Windows NT 3.51, the following error message displays:

    "VB caused a General Protection Fault in module GRID16.OCX at 0001:752D"

To work around this problem, change the code in the Click event of the button to:

   Private Sub Command1_Click()
      If Text1.Text = "" Then
         Grid1.Clip = ""
      Else
         Grid1.Clip = Text1.Text
      EndIf
   End Sub
                

Keywords: kbbug KB150229