100 pts.
 Run time error
VB6
When i run a progress bar in VB I get message "Run time error 380 Invalid property value" how to solve this

Software/Hardware used:
VB6, ACCESS
ASKED: January 30, 2010  2:12 PM
UPDATED: February 4, 2010  2:40 PM

Answer Wiki:
Most likely you are assigning a value outside the valid range (0 - 100) to the 'value' property.
Last Wiki Answer Submitted:  February 1, 2010  2:51 pm  by  carlosdl   63,535 pts.
All Answer Wiki Contributors:  carlosdl   63,535 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

I have given range 0 to 50. The code “Pb.value=pb.value+1 is highlighted as run time error

 100 pts.

 

We would need to see the complete code to try to help.
Are you sure the loop is not going farther than 100 interations ?

To debug it, try adding some code like this, replacing the line that is causing the error:

If Pb.value >= 100 then
	MsgBox("Value is already 100")
else
	Pb.value=pb.value+1
End If
 63,535 pts.

 

I have set Max as 50 and Min as 0 and the code is this

Private Sub Timer1_Timer()
PB.Value = PB.Value + 1 -> (After pb reaches max it displays as per code but then shows the run time error highlighting this line of code)
If PB.Value = 5 Then Label3.Visible = True
If PB.Value = 10 Then Label3.Visible = False
If PB.Value = 15 Then Label3.Visible = True
If PB.Value = 20 Then Label3.Visible = False
If PB.Value = 25 Then Label3.Visible = True
If PB.Value = 30 Then Label3.Visible = False
If PB.Value = 35 Then Label3.Visible = True
If PB.Value = 45 Then Label3.Visible = False
If PB.Value = 49 Then
Label3.Visible = True
PB.Visible = False
Label5.Visible = False
End If
End Sub

 100 pts.

 

I think I understand the problem now. You assigned min and max through the control properties.

When you do that, you are setting the valid range, but that doesn’t stop you from trying to assign values outside that range, so you have to make sure that doesn’t happen.

You have to check the value you are going to assign. Something like this:

Private Sub Timer1_Timer()
	If PB.Value < PB.max Then
		PB.Value = PB.Value + 1 -> (After pb reaches max it displays as per code but then shows 
	Else
		'Something else
	End If
	If PB.Value = 5 Then Label3.Visible = True
	...	
	...
End Sub
 63,535 pts.

 

Thank you that solved my problem

 100 pts.