×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Visual Basic .application values will not update

Visual Basic .application values will not update

Visual Basic .application values will not update

(OP)
Hello all,

I am a novice programmer, and have recently began creating simple calculator applications using Visual Basic (I am a power engineer... these are small applications for basic but tedious calculations).  

I have often found that after I enter all my data and return a result, if I change a few input values and recalculate, the results will not update.

I am only using text boxes and radio buttons to input information, and a single button to calculate the results.  

I have noticed that if I change a radiobutton to a selection that I do not want, hit my calculate button, then return my radio button to my desired selection and hit calculate once more, it will work.  Even this does not always work, however.  It seems I must change the radiobutton setting several times.

Finally, this situation has occurred on all of my created applications that do implement a radio button.

Is there something that I am missing, or has anyone run into this before?   

RE: Visual Basic .application values will not update

Do you want it to automatically recalculate when you choose a different radio button, or do you mean that when you change the input and hit recalculate you do not get the action you were expecting?

RE: Visual Basic .application values will not update

(OP)
I will choose a different radio button, hit recalculate, and the result does not change.  I put in a textbox with the radio button variable linked to it, and it does not change.  If I recycle, however, (select the desired button, another button, and the desired button), it often works.   

RE: Visual Basic .application values will not update

Can you post some relevant code, or if you don't want to post it to the internet, maybe some example code that demonstrates your problem?

Offhand, I would say it sounds like the recalculate routine is not updating values for some radio buttons before it runs. Perhaps add some code to the 'on change' event for the radio buttons to update values?

Which version of Visual Basic are you using?

RE: Visual Basic .application values will not update

You have to read all the textbox and options, all input values, each time you recalculate.  Your calculation subroutine needs to look like these,

sub calculate()
  a = value(txtBoxA.text)
  b= value(txtBoxB.text)
  c = value(txtBoxC.text)
  d = a * b * c 'or whatever
  txtBoxD.text = format(d,"###.##")
end sub

**********************
"The problem isn't finding the solution, its trying to get to the real question." BigInch
http://virtualpipeline.spaces.live.com/

RE: Visual Basic .application values will not update

If I remember a similar situation - you need a "CALC" button that actaully re-reads all your input and redoes the calculation. OR

When you exit a text box - I think you can see that event and go to your calc sub-routines each time.

RE: Visual Basic .application values will not update

Ya you could recalculate on each keypress event too, but that could get pretty messy.  A direct to a sub on a control's "lose focus" event would work, but as I recall, that event doesn't actually fire until you click on another control, which is why I probably settled on the re-read input method inside the calc button for a more uniform "feel".  That method doesn't require any additional lines of code either, which you'd get a lot of if you had many inputs and had to put a sub's name under the lostfocus event of each one of them.

**********************
"The problem isn't finding the solution, its trying to get to the real question." BigInch
http://virtualpipeline.spaces.live.com/

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources