Solved

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

Posted on 2006-11-30
5
148 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

733 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