Visual Basic Q&A

As a software engineer, I focus on .NET, especially asp.net, C#, WCF and so on, and I am also very interested in Search Engine Optimization.

Entries for July, 2010

BUG: Error When Data Control Is Set to a Wrong Text Database

Symptoms
A 16-bit Visual Basic for Windows version 4.0 program containing a Datacontrol with a Connect property set to Text and the DatabaseName propertyset to a non-text database generates an application error when run. Theapplication error displays the message – VB caused a General ProtectionFault in module VB.EXE at 003F:2106. Choose close. VB will close.
A 32-bit Visual Basic for Windows version 4.0 program with the same controlset to the same property displays the error message – Couldn’t find object.
Resolution
Microsoft has confirmed this to be an issue in the Microsoft productslisted at the beginning of this article. Microsoft is researching thisissue and will post new information here in the Microsoft Knowledge Baseas it becomes available.

BUG: Error Occurs When Printing a Form Stored in an Array

Symptoms
An application error occurs when calling the Print method of a form objectcontained within a form array.
Resolution
To work around this problem, define a non-array form variable and set thevariable to reference the form array element that you want to manipulate.Once this variable has been initialized, you can safely call the Printmethod of the newly defined Form variable, as shown in the example below:

Private Sub Form_Load()Dim MyForm As FormDim fl(1) As Form2Set fl(0) = New Form2Set MyForm = fl(0)MyForm.Show’Show the Form2 formMyForm.Print ‘Print the form to the screenEnd Sub

BUG: Error in CoolBar Event Can Cause Hanging or Exception

Symptoms
When using a CoolBar control, your compiled application hangs or generatesan exception error or invalid page fault (IPF.)
Resolution
An unhandled error occurred in one of the CoolBar’s Events.

BUG: Error at run time after you upgrade a Microsoft Visual Basic 6.0 project that uses the ImageList control to Microsoft Visual Basic .NET

Symptoms
When you upgrade a Microsoft Visual Basic 6.0 project that uses the ImageList control to a Microsoft Visual Basic .NET project by using the Microsoft Visual Basic .NET Upgrade Wizard, you receive the following exception when you run the project in Visual Basic .NET:

An unhandled exception of type ‘System.Runtime.InteropServices.COMException’ occurred in axinterop.mscomctllib.dll
Resolution
The Visual Basic .NET Upgrade Wizard wraps the ImageList control in the AxHost class. However, it does not modify the corresponding Visual Basic 6.0 code to access the underlying ImageList control. For example, the following code may be part of the migrated Visual Basic .NET code.

ListView1.ColumnHeaderIcons = ImageList