03-19-2010 08:23 AM
The Level = (PowerMeter.ReadString()) command at the end of the instrument setup sub returns the power level to Label3.Text at the end of the sub just fine. But the same command in the do while loop in button2 event handler does not refresh the display in form1 as I thought it would (please see attached). Can someone tell me what’s wrong ? Also, when using multiple devices is it always necessary to re-dimension them in each sub. I think it works ok but is seems “klunky”. Is there a better way?
03-19-2010 09:54 AM
This is really a VB.NET question. The label cannot be refreshed because Windows is busy handling your event. You have an infinite loop in your event handler, so there's no opportunity for Windows to handle system events, such as redrawing the control. You need to add an Application.DoEvents() call after writing the .Text value. Of course, a better solution is not to have an infinite loop inside an event handler, as this basically locks up your application. I would suggest using a Timer object.
I don't understand the second quesiton.