Solved

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

Posted on 2006-11-30
5
146 Views
Last Modified: 2010-04-30
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!
0
Comment
Question by:amlp
  • 3
5 Comments
 
LVL 4

Accepted Solution

by:
seshu123 earned 125 total points
ID: 18051476
Hai,
   Try to use the timer control which will ticks for every 3 seconds and sets the current value the text box.  for this purpose pls. add a timer control on the form and set the interval to 3000  and in that timer event writ the following.

private sub timer1_timer()
   Text15.Text = Setpoint
end sub


This will resolve your problem.




Seshu123
0
 
LVL 11

Expert Comment

by:Dany Balian
ID: 18051756
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

0
 
LVL 4

Expert Comment

by:seshu123
ID: 18053253
ofcourse,
  But for the virtual recordset you have to refresh the recordset for every time.

seshu123
0
 
LVL 3

Expert Comment

by:gajendra
ID: 18053416
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
0
 
LVL 4

Expert Comment

by:seshu123
ID: 18084225
Hai,
   Did the suggestion worked for you.


Seshu123
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question