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 Tagged ‘visual basic application’

BUG: Data Form Wizard Through Application Wizard Omits ADO Reference

Symptoms
When you run an application that is created using the Visual Basic Application Wizard, you receive the following error message:

Compile error: User-defined type not defined
Resolution
The Application Wizard allows for the creation of forms via the Data FormWizard. When a form is created in this manner, a reference to ADO is notadded to the project.

PRB: Run-Time Error 713 Opening Data Report in Distributed Application

Symptoms
You are distributing a Visual Basic application that includes a data report. After installation, you receive the following error when you attempt to open the data report from your application:

Run-time error ‘713′:Application-defined or object defined error
Resolution
The Data Report run-time file (Msdbrptr.dll) was not included in your setup package.

BUG: Visual Basic Does Not Create an EXE File After Compiling

Symptoms
An EXE file is not created even though no errors are produced aftercompiling a Visual Basic application that includes a resource file.
Resolution
This will occur when including a resource file which contains a “Version”resource.

Automation Error Using Excel Object in Visual Basic Procedure

Symptoms
When you use a Visual Basic application to create an OLE Automation objectusing Microsoft Excel, you may receive the following error message when youattempt to access the object:

OLE Automation error
Resolution
This problem occurs when you access a Microsoft Excel OLE Automation objectin a Visual Basic procedure while Microsoft Excel is closed. If, forexample, you create a reference for a worksheet object using theCreateObject function, and you create a reference for another MicrosoftExcel object using the GetObject function in your procedure, if you thenset the Microsoft Excel worksheet object (Excel.Sheet) equal to nothing,you receive the OLE Automation error message if you then try to access theother object.
This problem occurs because setting a Microsoft Excel object that wascreated using the CreateObject function equal to Nothing closes MicrosoftExcel, even if your Visual Basic procedure still has a reference to anotherMicrosoft Excel object.
For example, you receive this error message when you run the following codein Microsoft Visual Basic:

Dim xlSheet As ObjectDim xlApp As ObjectSet xlSheet = CreateObject(“Excel.Sheet”)MsgBox xlSheet.Application.NameSet xlApp = GetObject(, “Excel.Application”)MsgBox xlApp.NameSet xlSheet = NothingMsgBox xlApp.Name You receive this error message because the statement “Set xlSheet =Nothing” closes Microsoft Excel, and the “MsgBox xlApp.Name” statement thatfollows in the procedure attempts to access the Microsoft Excel applicationobject again.
Note that in the above example, if you set the Microsoft Excel applicationobject equal to nothing (Set xlApp = Nothing), you do not receive an errormessage if you then access the Microsoft Excel worksheet object (xlSheet)in the procedure. Additionally, you do not receive this error message ifMicrosoft Excel is running when you run this macro because, in this case,the CreateObject function starts another instance of Microsoft Excel.

PRB: Cannot Use Data Transformation Services Event Handlers in Visual Basic with Execute Package Task

Symptoms
If you install Data Transformation Services (DTS) Package event handlers in a Visual Basic application, and the package you call uses an Execute Package task to call another package, an Exception Access Violation (AV) similar to the following may occur:

(1:Child Package) SubStep ‘<title of step> Step’ failed with the following error:
Need to run the object to perform this operation
(Microsoft Data Transformation Services (DTS) Package (80040005):
Provider generated code execution exception:EXCEPTION_ACCESS_VIOLATION)The Access Violation occurs when these conditions are true:You use DTS package event handlers in the Visual Basic application.You use a parent DTS package that uses an Execute Package task to call a child DTS package.
Resolution
Threading limitations in the design of Visual Basic 6.0 prevent the nested child package from reporting it’s events up through the parent package’s event handler.

FIX: Adding Subitems To Hidden ListView Causes APP Error

Symptoms
A 32-bit Visual Basic application with a ListView control can generate anapplication error or incorrectly display the subitems if the subitems areadded to a ListView control that is hidden on a form.
Resolution
To eliminate this behavior, use one of the following methods:
If you want your ListView control in the form to be hidden when the formis shown, toggle the Visible property once before adding the subitems tothe ListView control. To toggle the Visible property, initially set theVisible property to True and then reset the Visible property to False.
-or-
At design time, set the ListView control Visible property to True. Then inthe first line of code in the form’s Load procedure, set the ListViewcontrol Visible property to False.