Solved

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

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

758 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now