Difference between revisions of "Strange Errors & Behavior in VB6"

From Free Knowledge Base- The DUCK Project: information for everyone
Jump to: navigation, search
m
m (Check Boxes Sometimes vbChecked/vbUnchecked (1/0) and Sometimes True/False)
 
(2 intermediate revisions by one user not shown)
Line 26: Line 26:
  
 
''I think that the issue has to do with the way VB matches the text from the listed item with the text entered using the .text property.  Typically characters are matched and what is entered with .text works fine.  In this case it is perhaps something to do with the characters within the listed item.  Most of the time the first method would not cause a problem.  Sometimes it is just better to find a different way to do the same thing and move forward.''
 
''I think that the issue has to do with the way VB matches the text from the listed item with the text entered using the .text property.  Typically characters are matched and what is entered with .text works fine.  In this case it is perhaps something to do with the characters within the listed item.  Most of the time the first method would not cause a problem.  Sometimes it is just better to find a different way to do the same thing and move forward.''
 +
 +
== Check Boxes Sometimes vbChecked/vbUnchecked (1/0) and Sometimes True/False ==
 +
 +
Ever experience inconsistant CheckBox values?  Your checkbox is checked yet code treats it as unchecked.  Another stupid Microsoft glitch, or more likely, an oversight by their 3rd rate engineers.
 +
 +
Illustrated best with this sample program:
 +
 +
[[Image:vbchecked01.png]]
 +
 +
[[Image:vbchecked02.png]]
 +
 +
Option Explicit
 +
 +
Private Sub cForms2_Click()
 +
  tStandard.Text = cStandard.Value
 +
  tForms2.Text = cForms2.Value
 +
End Sub
 +
 +
Private Sub cStandard_Click()
 +
  tStandard.Text = cStandard.Value
 +
  tForms2.Text = cForms2.Value
 +
End Sub
 +
 +
Private Sub Form_Load()
 +
  tStandard.Text = cStandard.Value
 +
  tForms2.Text = cForms2.Value
 +
End Sub
 +
 +
The Fix: Stick with the standard checkbox only or Forms 2.0 checkbox only throughout the software you are developing. 
  
 
 
 
 

Latest revision as of 21:33, 12 February 2008

Automation error, The object invoked has disconnected from its clients.

Runs in IDE (Interpreted), Yet (Compiled) .exe Crashes

This error is not generated when the project is ran within the IDE. It is generated when the compiled exe is executed.

Searching Google lead me down the wrong road thinking it was ADO related, as did the Microsoft Knowledge Base. It turns out the error was being generated by setting text in a ComboBox control. The error is, therefore related to the ComboBox Control in VB6.

AutomationErrorbyComboBox.png

When ran in the Visual Basic IDE, the error is NOT generated. The error is only generated in the compiled exe version of the project. Debugging within the IDE alone is not helpful. The error was tracked down using a series of MsgBox messages.

Setting the default value to the cboBox like this is probably not "by the book".

Possibe Key terms:

  • circular references

The Fix:

The following simplified code sample is what renders the error from the compiled exe.

 cboSkGroup.AddItem ("<All Skill Groups Available>")
 cboSkGroup.Text = "<All Skill Groups Available>"

The following code has been substituted and thus resolved the error.

 cboSkGroup.AddItem ("<All Skill Groups Available>")
 cboSkGroup.ListIndex = 0

I think that the issue has to do with the way VB matches the text from the listed item with the text entered using the .text property. Typically characters are matched and what is entered with .text works fine. In this case it is perhaps something to do with the characters within the listed item. Most of the time the first method would not cause a problem. Sometimes it is just better to find a different way to do the same thing and move forward.

Check Boxes Sometimes vbChecked/vbUnchecked (1/0) and Sometimes True/False

Ever experience inconsistant CheckBox values? Your checkbox is checked yet code treats it as unchecked. Another stupid Microsoft glitch, or more likely, an oversight by their 3rd rate engineers.

Illustrated best with this sample program:

Vbchecked01.png

Vbchecked02.png

Option Explicit 

Private Sub cForms2_Click()
  tStandard.Text = cStandard.Value
  tForms2.Text = cForms2.Value
End Sub

Private Sub cStandard_Click()
  tStandard.Text = cStandard.Value
  tForms2.Text = cForms2.Value
End Sub

Private Sub Form_Load()
  tStandard.Text = cStandard.Value
  tForms2.Text = cForms2.Value
End Sub

The Fix: Stick with the standard checkbox only or Forms 2.0 checkbox only throughout the software you are developing.