Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hello I hope you can help me. I am

Status
Not open for further replies.

samuel wells

Programmer
Oct 13, 2019
3
US
Hello I hope you can help me. I am a programmer, but new to VB6 my problem is as follows: I write automatic test software. I am using shapes to let me know what position a switch is in by changing the color of the shape is red or black. here is the code:

Private Sub Command1_Click()
Dim ldTime As Double
For x = 1 To 5

Call POS2

ldTime = Timer
While Timer < (ldTime + 2)
Call changecolor
Wend
Call POS1

ldTime = Timer
While Timer < (ldTime + 2)
Call changecolor2
Wend
Next
End Sub


Private Sub changecolor()
Shape1.BackColor = vbBlack ' &HFF&
End Sub

Private Sub changecolor2()
Shape1.BackColor = vbRed ' &H0&
End Sub

With this code the colors do not change, but if a add a MsgBox after each call to pos1 and pos2 the colors change.

Please help.
 
> I am using shapes

This would suggest that actually you are NOT using VB6, but VBA - which is a slightly different kettle of fish

You might want to ask this in forum707, or possibly forum68
 
Your use of both Shapes and Timer both disagree with your assertion. I suspect that perhaps you have been misled by an About Microsoft Visual Basic dialog in your Office application such as:

VB65_ugxjkq.png


the actual language you are using is shown at the bottom of the dialog, in this particular instance VBA 6.5.1057 (the most recent versions of Office are more explicit about this since Microsoft figured out people were getting confused)

That being said, the easiest solution to your issue - whether VB or VBA - is to put a DoEvents at the end of each of the [tt]changecolour[/tt] procedures.
 
Thank you so much strongm for your help and education, it works perfect.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top