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 ‘Windows’

BUG: Visual Basic SendKeys causes incorrect keyboard status or freezes keyboard

Symptoms
You have a Microsoft Visual Basic program that uses the SendKeys function. The program works fine on Windows 95, Windows 98, or Windows NT-based computers. However, when you run the application on Windows 2000, either from the Desktop or through Terminal Services, the keyboard may freeze or go into an incorrect status.
Resolution
On Windows NT and Windows 2000, the Visual Basic SendKeys function toggles NUM LOCK, CAPS LOCK, and SCROLL LOCK when they are on. The Windows 2000 keyboard driver may not handle this behavior correctly, which causes the keyboard status to be incorrect or the keyboard to freeze.

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: Design Option in Pop-up Menu Data View Window Not Available

Symptoms
If you use a Windows NT 4.0 computer and are not a member of the administrators group, you will not get the Design option in the pop-up menu for a table when you right-click on on the table in the Data View Window of Microsoft Visual Basic 6.0.
NOTE: This bug does not occur on Windows 2000 machines.
Resolution
The Visual Basic IDE is incorrectly determining that the Design option should not be shown unless you belong to the administrators group.

BUG: All check boxes are cleared in a data-bound CheckedListBox control when rows are added to the DataTable control

Symptoms
You have a data-bound CheckedListBox control on your Windows Form. When you click to select some items in the CheckedListBox control at runtime and then you add a new row to the DataTable control that is bound to the CheckedListBox control, all the check boxes on the control are cleared.
Note Check boxes are not cleared when the CheckedListBox control is not data-bound.
Resolution
This problem occurs because the CheckedListBox control is not designed for data binding.

PRB: GetChunk Corrupts Binary Data on Win98/NT4 SP4

Symptoms
When using the Data Access Objects (DAO), Remote Data Objects (RDO) or the ADO GetChunk method, on a long binary field of a Microsoft Access database, binary data may appear corrupt if the binary information previously stored was read from disk using a String (BSTR) variable instead of a Byte array. The problem occurs under one of the following conditions:
You recently upgraded your computer to Windows 98 or Windows NT version 4.0 SP4. Previously stored data now appears corrupt.
-or-You are using a shared database. The corruption occurs when the binary data was stored by clients running on Windows 95 or Windows NT 4.0 SP3, and then extracted by clients running Windows 98 or Windows NT 4.0 SP4 or vice versa.
Resolution
The problem is that the information stored to the database is mistakenly being converted to Unicode before being stored. The “corruption” occurs when reading the information from disk using the Visual Basic or Visual Basic for Applications Get statement.
By design, the Get statement relies on the data type of the variable to determine how the information should be read into Visual Basic. If you pass a String (BSTR) variable to the function, Visual Basic identifies the information as being a text string, and converts it to Unicode. However, since the data is binary and not text, this conversion corrupts the data before it is ever stored to the database.
Although binary data stored in Unicode format can be “decoded” in some cases, it requires that the Unicode symbol table used to map 1-byte ANSI characters to 2-byte Unicode characters be the same for both the conversion to and the conversion from Unicode. Due to the recent addition of the European Currency symbol, the symbol table for Windows 98 and Windows NT 4.0 SP4 is different from those used previously. These changes will have no effect on text strings, but can effect binary data mistakenly converted to Unicode.

INFO: VB 6.0 Readme Part 1: Important Issues – Read First!

Symptoms
The information below includes the documentation and workarounds for VisualBasic 6.0. This information can also be found in the README.htm file thatships with Visual Basic 6.0 on the Visual Basic 6.0 CD-ROM. Please see theREFERENCES section of this article for a list of the Microsoft KnowledgeBase articles relating to the Visual Basic 6.0 readme.
Following is a list of all parts of the readme file:
Part 1.Important Issues – Please Read First!
Part 2.Data Access Issues and DataBinding Tips
Part 3.Control Issues
Part 4.Language Issues
Part 5.Samples Issues
Part 6.Wizard Issues
Part 7.Error Message Issues
Part 8.WebClass Designer Issues
Part 9.DHTML Page Designer Issues
Part 10. Extensibility issues
Part 11. Miscellaneous Issues
Part 12. Microsoft Transaction Server (MTS) Issues
Part 13. Dictionary Object
Part 14. Visual Component Manager
Part 15. Application Performance Manager
Resolution
Passing User-Defined Types to ProceduresWith Visual Basic 6.0 it is possible to pass a user defined type (UDT) asan argument to a procedure or function. However, there is a restriction.Passing a UDT to a procedure in an out-of-process component or acrossthreads in a multi-threaded component requires an updated version of DCOMfor Windows 95 and Windows 98, or Service Pack 4 for Windows NT 4.0. Thisupdate is required on your development computer as well as on any computerthat will run your application. A run-time error will occur if the requiredfiles are not installed.
The above does not apply to passing UDTs within a single-threadedapplication; this will work without updating. The Package and DeploymentWizard will not determine the dependencies for the necessary components -it is up to you to make sure that the files are on the end user’s computer.You can test for the existence of the components by trapping for run-timeerror 458 – “Variable uses an Automation type not supported in VisualBasic”. If this error occurs, the DCOM or Service Pack components must beupdated; the update procedure differs depending on the operating system:
Windows 95 or Windows 98
DCOM98.EXE is a self-extracting executable that installs the updatedDCOM components for Windows 95 or Windows 98. It can be found in theDCOM98 directory of the Visual Basic 6.0 CD. This file may be freelydistributed with your Visual Basic application.Windows NT 4.0
The updated DCOM components are automatically installed with ServicePack 4 (SP4). When it is released, you can download the Service Packfrom the Microsoft Web site.
Searching Online by Topic TitleTo search for a topic when you have the title:
In the navigation pane of the MSDN window, click the Search tab and thentype or paste the title of the topic you want to find. Enclose thesearch string in quotation marks.Click Search Titles Only.Click List Topics. (If your search returns more than one hit, you cansort the topic list by clicking the Title or Location column heading.)Select the title of the topic you want and then click Display.
To find where a topic is located in the table of contents, click theLocate button on the toolbar. The table of contents will synchronizewith the topic you are viewing.
NOTE: The Locate button is unavailable for the topics in the Referencenode of the Visual Basic documentation.Cross References to Internet Client SDK
Refer to the Internet/Intranet/Extranet SDKIn the Building Internet Applications book within the Component ToolsGuide, multiple cross references are made to a part of MSDN referred to asthe “Internet Client SDK.” The correct name for this SDK is the”Internet/Intranet/Extranet SDK.” When searching for an Internet Client SDKreference in MSDN, please look in this section.
Context-Sensitive HelpTo use Help buttons and the F1 key to access Help without having the MSDNCD in your CD drive, you must choose the Custom install option during setupof the MSDN Library. Check the boxes labeled “VB Documentation,” “VBProduct Samples,” and “VS Shared Documentation.” You may also want to check”VSS Documentation” if you are using Visual SourceSafe.
Sample Code Sometimes Does Not Cut and Paste ProperlyLine breaks and formatting information may not copy correctly when you copyand paste sample code from the MSDN Library Visual Studio documentation toyour code editor. To work around this issue, do one of the following:
Manually edit the line breaks after you copy the code.View the sample code source, copy the entire code sample, including the<pre> and </pre> tags, paste it to your code editor, and then delete theunwanted sections from the pasted version.
Locate Button Disabled for Reference TopicsWhen you find a language reference topic in MSDN through the Search tab,you cannot use the Locate button to find where the topic is located in theMSDN Table of Contents tree.