Link to home
Start Free TrialLog in
Avatar of teogos
teogosFlag for United States of America

asked on

Values from Textbox to another Textbox

I have a textbox1 which get the values for a total of listbox

This happens an a timer tick 1 minute
I want this value of textbox1 to be trasfer to textbox2
Example:
if textbox1=200  when the timer times out  thansfer this 200 to textbox2

but now textbox1 has a value  of 300, how can I compare the two values a put the difference into textbox3


the timer runs all the time
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

In the simplest form:

    TextBox3.Text = CInt(TextBox1.Text) - CInt(TextBox2.Text)

You should probably store the actual values in a Numeric variable though, and do the calculations with those.
Avatar of teogos

ASKER

Not that choice will  work, I have it like that already.  What is happening is that the
value of textbox1  is getting overwrite with  the new value that comes in when the timer times out, so when I do
TextBox3.Text = CInt(TextBox1.Text) - CInt(TextBox2.Text)

the textbox1 and textbox2 are the same value, somwhow  I need to get the value of textbox1 before the timer times out and store this value somewhere to use it on
TextBox3.Text = CInt(TextBox1.Text) - CInt(TextBox2.Text)
Do the above before you transfer the value to textbox2. So put this code in timer_tick event first and then the code which copies the value.

If you want, you can also use a class level variable to store the previous value.
Right...like I said as well, create actual variables to store those values (instead of storing them directly in the TextBoxes).
Avatar of teogos

ASKER

Please post a sample of class level variable and how to use it
ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

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 teogos

ASKER

On the listbox was not exactly what I want this, since I am doing the accumulation of items from a gridview, but I got that change , the other part of your code works, Thanks