BUG: Setting Grid Clip Property to Empty Text Box Causes GPF (150229)



The information in this article applies to:

  • Microsoft Visual Basic Professional Edition, 16-bit, for Windows 4.0
  • Microsoft Visual Basic Enterprise Edition, 16-bit, for Windows 4.0

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
				

Modification Type:MinorLast Reviewed:1/9/2003
Keywords:kbBug KB150229