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

BUG: TextBox content is not automatically scrolled to display selected text on receiving focus

Symptoms
When you programmatically select the content of a text box, and the selected content resides in the area that you cannot see of the TEXTBOX control, then the text in the text box does not scroll automatically to display the selected text. Also, when you move to the TEXTBOX control by pressing TAB, the selected text does not appear automatically when the text box receives the focus.
Resolution
To work around this problem, you can use the ScrollToCaret method of the TEXTBOX control. This method scrolls the content of the control to the current caret position.
Copy the following code to the textBox1_Enter event:
Visual Basic Code

textBox1.ScrollToCaret()Visual C# Code

textBox1.ScrollToCaret();

BUG: Text Box and Data Control on a UserControl Closes UserControl in the IDE

Symptoms
A Standard EXE or UserControl form contains a second UserControl. The second UserControl contains a text box and a data control. You close all the forms and then open the second UserControl. When you attempt to change the DataSource property of the text box in the property window, the UserControl immediately closes or an application error occurs that causes Visual Basic to stop responding.
Resolution
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

BUG: Error 424 Adding Data Object Wizard-Created Ctrl to Form

Symptoms
When you try to place a user control that was created using the Data ObjectWizard onto a form, Error 424 (“Object Required”) occurs.
Resolution
When you place a user control on a form, that control’s Resize event isexecuted. If you create a list box or combo box type of user control usingthe Data Object Wizard, that control’s Resize event refers to the containedlist box or combo box incorrectly and causes error 424, “Object required.”

INFO: VB 6.0 Readme Part 15: Application Performance Explorer

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 TipsPart 3.Control IssuesPart 4.Language IssuesPart 5.Samples IssuesPart 6.Wizard IssuesPart 7.Error Message IssuesPart 8.WebClass Designer IssuesPart 9.DHTML Page Designer IssuesPart 10. Extensibility issuesPart 11. Miscellaneous IssuesPart 12. Microsoft Transaction Server (MTS) IssuesPart 13. Dictionary ObjectPart 14. Visual Component ManagerPart 15. Application Performance Manager
Resolution
Known Problems in Application Performance Explorer:
Configuring Remote Automation Security When Using Remote APE ComponentsIn order to use Remote Automation (RA) to communicate with remote APEcomponents, you may have to configure RA security using the RemoteAutomation Connection Manager (Racmgr32.exe).
To configure RA security:
Start Racmgr32.exe and click the Client Access tab.Select either “Allow All Remote Creates” or “Allow Remote Creates byKey”.If “Allow Remote Creates by Key” is selected, make sure the “AllowRemote Activation” check box is checked for each APE component.RA supports the following levels of authentication:

NameValueDescription———————————————————————Default0Use Network default.None1No authentication.Connect2Connection to the server is authenticated.Call3Authenticates only at the beginning of eachremote procedure call, when the serverreceives the request. Does not apply toconnection-based protocol sequences (thosethat start with the prefix “ncacn”).Packet4Verifies that all data received is from theexpected client.Packet5Verifies that none of the data transferredIntegritybetween client and server has beenmodified.Packet Privacy 6Verifies all other levels and encrypts theargument values of each remote procedurecall.
APE profiles are initially installed with an authentication level of 1(“None”) because Windows 95 supports only that level of authentication.However, if additional security is desired, the level of authentication ofa profile can be changed by modifying the profile collection file (theAemanagr.ini file) by using a text editor such as Notepad.
Each profile in the profile collection file begins with the name of theprofile within square brackets, such as [Peak performance, synchronous(CPU, Pool)]. The attributes of the profile follow, using the format<name>=<value> (such as “Task Duration=1″). To change the authenticationlevel, change the value of the “Authentication” attribute of the selectedprofile and save the file.
Compatibility Issues Between the Application Performance Explorer (APE)that Ships with Visual Studio 6.0 and the Version that Shipped with Visual
Basic 5.0There are known compatibility issues between the Application PerformanceExplorer (APE) that ships with Visual Studio 6.0 and the APE that shippedwith Visual Basic 5.0.
To avoid the compatibility issues, do one of the following:
Before installing Visual Studio 6.0 and APE on the computer that has theversion of APE shipped with VB 5, first uninstall APE from Visual Basic,and then install Visual Studio and APE.If you have installed Visual Studio 6.0 and APE on the same computerthat has the VB5 APE, uninstall the VB APE and then reinstall the VisualStudio APE.
Adjusting Default Settings To Use APE and MTSAfter installing the APETEST database onto your SQL Server, you must adjustsome of the default settings in order to use APE and MTS.
NOTE: If you haven’t already installed the APETEST database on your SQLServer, you should do that first. To learn how to install the APETESTdatabase, search for the topic “APE Database Setup Wizard” in MSDN LibraryVisual Studio 6.0.
To configure the APETEST database installation to work with MTS:
Start Microsoft SQL Enterprise Manager.In the Databases folder, right-click the APETEST database and clickEdit.Click the Options tab.Select the Truncated Log on Checkpoint check box and click OK.In the Databases folder, right-click the tempdb database and click Edit.Click Expand.In the Data Device box, select <new>.In the New Database Device dialog box, in the Name box, type tempdbData.In the Size (MB) box, type 10.Click Create Now, and finally click OK.Click Expand Now.Click Expand.In the Log Device box, select <new>.In the New Database Device dialog box, in the Name box, type tempdbLog.In the Size (MB) box, type 10.Click Create Now, and finally click OK.To configure the allowable number of user connections:
Start Microsoft SQL Enterprise Manager.Right-click the server and click Configure.For example, if your server is named CORONA, in the Server Manager childwindow, right-click CORONA and then click Configure.Click the Configuration tab.In the Configuration box, increase the number of user connections by atleast 15.
NOTE: If you are running APETEST on an established production databaseserver, you may not have access permission to adjust the current number ofuser connections. In this case, you should ask your database administratorto increase the number of current user connections by at least 15connections to support APE testing.
Application Performance Explorer Server-Side Setup May Generate ErrorWhile installing the APE server-side components, you may see an errorreferring to an incorrect version of OLEAUT32.dll. You may dismiss thiserror and continue with the installation.
However, this error message may indicate that the Microsoft TransactionServer Package was not installed correctly. To confirm that it wasinstalled correctly, run the Transaction Server Explorer and look for allinstalled MTS packages on your computer. Visual Studio APE Package shouldbe listed.
To install the package, AEMTSSVC.pkg, run the MTS Transaction ServerExplorer from the Start menu and install the package to the local computerusing the MTS Explorer.

FIX: Can’t Have Menu with No Caption Bar/Buttons/Control Box

Symptoms
You can’t add a menu that has no caption, no maximize/minimize buttons,and no control-menu box to a form.
Resolution
This feature is not supported in Visual Basic in Windows version 3.0or 3.1 because of a bug in the Microsoft Windows menu driver thatprevents Windows from painting menus correctly.

BUG: Data in Bound Text Box Does Not Return to Original Value After CancelUpdate If Changed in Code

Symptoms
When you update a bound text box by setting its text property in code, and then you call a CancelUpdate method, the value in the field does not revert to its original value.
Resolution
Instead of setting the text property of the bound text box, set the value of the underlying recordset field directly, as follows:

Adodc1.Recordset!LastName = “Smith”
The bound text box should update itself after you run the code. Subsequent calls to the CancelUpdate method then work as expected, and change the text box contents back to its original value.