Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Why doesn't my HP437B refresh the display in form 1

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?

0 Kudos
Message 1 of 2
(3,178 Views)

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.

0 Kudos
Message 2 of 2
(3,165 Views)