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

PRB: Type Mismatch with Default Prop of VB4 Data Access Object

Symptoms
Some data access objects in Visual Basic for Windows version 4.0 no longerhave the default “Name” property. Instead, these objects now have a defaultcollection. This change can lead to “Type Mismatch” (Error 13) or “InvalidArgument” (Error 3001) errors when attempting to run your code.
Resolution
To work around this problem, add the name of the property you want toreference.
For example, use this:

MsgBox Data1.Database.TableDefs(0).Name instead of this:

MsgBox Data1.Database.TablesDefs(0)

PRB: RDC/ODBC Password Display Inconsistencies

Symptoms
When setting the password property of the RemoteData Control (RDC) atdesign time in the Property Window, asterisks are not substituted for thepassword characters. When the ODBC dialog box is displayed, the password isconverted into asterisks.
Resolution
The RDC does not control the edit field in the Property Window, andtherefore cannot force asterisks to be displayed. An OLE custom controldoes not have direct control over the Property window supplied by theVisual Basic design environment. The Remote Data control does correctly useasterisks in its own Property page.

BUG:Wrong Default Value in Remote Data Object MaxRows Property

Symptoms
Some ODBC drivers require the MaxRows property of the Remote Data Object tobe set to 0. The default value for this property is -1.
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: The Text property of a data-bound ComboBox returns an incorrect value when you set the value in code

Symptoms
If you programmatically set the Text property for a data-bound member of the ComboBox control, the value typed in the text box portion of the ComboBox is displayed as expected. However, the Text property and the SelectedIndex property incorrectly return the value of the last item that was selected in the list box instead of returning the value typed in the text box.
When you type in the ComboBox at runtime, Text property returns the typed value, and SelectedIndex returns a value of -1.
Resolution
To resolve this problem, set the SelectedIndex property to -1 before you set the Text property for a data-bound member of the ComboBox, as in the following examples. Visual Basic .NET

ComboBox1.SelectedIndex = -1ComboBox1.Text = “My Text” Visual C# .NET

ComboBox1.SelectedIndex = -1;ComboBox1.Text = “My Text”; NOTE: Do not use the Text property to select a data-bound member of the ComboBox. You must locate the item in the list that you want to show, and then set the SelectedIndex to the index of the item. You do not have to set the Text property.
For example, if you bind the DisplayMember property and the ValueMember property of the ComboBox to a list that contains the numbers 1 through 10, and you want the ComboBox to display the number 5 in the text box and show 5 as selected in the list, you must set the SelectedIndex property to 5.

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: Run-Time Error 380 “Invalid Property Value” with MaskEdBox

Symptoms
With Microsoft Visual Basic 4.0, when you set the Text property of a MaskEdit control at run-time, you receive the following error.

Run-time Error 380:
Invalid Property Value
Resolution
This error occurs under the following circumstances:
The Visible property of the Mask Edit control is set to False atdesign-time.
-and-A later version of MSMASK32.OCX is installed. The error occurs withMSMASK32.OCX version 5.00.3714, which ships with Microsoft Visual Basic5.0.