views:

2434

answers:

3

Hi all we had developed an application using vb6.0 and SQL server 2000 a few years ago. recently, some of our customers tell us that while running the application, on some of computers which use Winxp sp2 as their O/S, they get the following error when they want to show the search form:

"Runtime error 380: Invalid property value"

What causes this error?

+2  A: 

I presume your application uses a masked edit box? This is a relatively well known problem, documented by Microsoft here:

http://support.microsoft.com/kb/177088

The article refers to VB4 and 5, but I am pretty sure the same is true for VB6.

EDIT

On further research, I am finding references to this problem with other controls as well. Recompiling your application on Windows XP for users that are running XP will probably produce them a working version, though it's not an ideal solution...

David M
David,I checked it's MaskEditBox controls. Well, I saw 4 MaskEditBoxes on the search form but unfortunately, their visible property was true at design time.
odiseh
This error doesn't just happen due to bugs in Microsoft controls. It also occurs when you make a programming error, and accidentally set a property to a invalid value. Something different on the user machines is causing the different behaviour - e.g. Windows themes or different configuration of the application.
MarkJ
+1  A: 

What causes runtime error 380? Attempting to set a property of an object or control to a value that is not allowed. Look through the code that runs when your search form loads (Form_Load etc.) for any code that sets a property to something that depends on runtime values.

My other advice is to add some error handling and some logging to track down the exact line that is causing the error.

  • Logging Sprinkle statements through the code that say "Got to X", "Got to Y", etc. Use these to find the exact location of the error. You can write to a text file or the event log or use OutputDebugString.
  • Error handling Here's how to get a stack trace for the error. Add an error handler to every routine that might be involved, like this code below. The essential free tool MZTools can do this automatically. You could also use Erl to report line numbers and find the exact line - MZTools can automatically put in line numbers for you.

_

 On Error Goto Handler
   <routine contents>   
 Handler: 
   Err.Raise Err.Number, "(function_name)->" & Err.source, Err.Description 
MarkJ
Mark, It's Vb6.0 :( There's no way to get the exact line hat causes the error.
odiseh
@odiseh Don't give up yet, there's dozens of ways to get the exact line that causes the error. I've done it loads of times. I've edited my answer with some suggestions.
MarkJ
@odiseh: If you add line numbers to your code, Erl will return the line number the error occurred on.
Beaner
A: 

Just to throw my two cents in: another common cause of this error in my experience is code in the Form_Resize event that uses math to resize controls on a form. Control dimensions (Height and Width) can't be set to negative values, so code like the following in your Form_Resize event can cause this error:

Private Sub Form_Resize()
    'Resize text box to fit the form, with a margin of 1000 twips on the right.'
    'This will error out if the width of the Form drops below 1000 twips.'
    txtFirstName.Width = Me.Width - 1000
End Sub

The above code will raise an an "Invalid property value" error if the form is resized to less than 1000 twips wide. If this is the problem, the easiest solution is to add On Error Resume Next as the first line, so that these kinds of errors are ignored. This is one of those rare situations in VB6 where On Error Resume Next is your friend.

Mike Spross