Link to home
Start Free TrialLog in
Avatar of amlp
amlp

asked on

setting the displayed value of a variable so the displayed value is always the current value?

I've got a stream of data coming in via a modbus app.  The piece of data of interest is deposited in a variable of type 'long' named 'Setpoint' (for example).  Now, this variable Setpoint may change with the incoming modbus value BUT it may also change elsewhere in the VB program depending on various events and settings.  (this is obviously very simplified).

How do I set up a text box to always display the -current- value of Setpoint, no matter what it is, no matter where it's changed, no matter when it's changed?

Presumably it's a text box..if not, what should I be using?

One way is to go every single place that Setpoint may be affected, and put Text15.Text = Setpoint after it, but there's gotta be a better way.

Thanks!
ASKER CERTIFIED SOLUTION
Avatar of seshu123
seshu123

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Dany Balian
3 seconds seems a lot...
i recommend 0.5 seconds (500 as interval)

another hack would be to create a virtual recordset and bind a column in it to the textbox
the downside of this would be you still need to modify all your code from...

setpoint=value
to
rs("setpoint")=value

but will save u the refreshing of the textbox every x seconds!

hope this helps,

dan

Avatar of seshu123
seshu123

ofcourse,
  But for the virtual recordset you have to refresh the recordset for every time.

seshu123
Polling is a good idea.

But for the kind of problem you have outlined I would personally prefer to set up a class with maybe a shared member. Whenever the property value of this member is changed you could use RaiseEvent.

After that refreshing the property value on the screen should not be difficult.

HTH

Gajendra
Hai,
   Did the suggestion worked for you.


Seshu123