Solved

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

Posted on 2006-11-30
5
149 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

726 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