Summing the values in text boxes

  • Thread starter Thread starter cosmic mo
  • Start date Start date
C

cosmic mo

I am working with a user form that has three text boxes. The text boxe
are connected to three scroll bars. When the user adjusts the scrol
bars, the text box values change accordingly, or the user can manuall
enter a value into each box.

I would like to have a fourth text box that is a sum of the previou
three. I've tried a few things, but with no luck. As the user change
each box, the total in the fourth box should adjust accordingly.

Does anyone have any ideas on how to get this to work? I've trie
this...

txt4 = txt1.value + txt2.value + txt3.value

Thank
 
Generally speaking that should work, but you need to run that code when any
of the textboxes change... Another thing to try would be to convert the
values to numbers (text boxes hold text strings)...

txt4 = cdbl(txt1.value) + cdbl(txt2.value) + cdbl(txt3.value)
 
Hi Cosmic mo

Could you teach me please how you setup the connection between a textbox and
a scroll bar such that when the user adjusts the scroll bar, the textbox
immediately changes - even before the user lifts their finger off the mouse.


Thanks

Phil
 
Hi Phil,

Here is the code I used for one scroll bar. There are two separate
subs I wrote for each scroll bar on my form.

This one will change the values when the user clicks the scroll bar
arrows, or clicks anywhere within the bar...

Private Sub scrCost_Change()
txtCost = scrCost / 100
End Sub

This one will change the value when the user drags the scroll bar...

Private Sub scrCost_Scroll()
txtCost = scrCost / 100
End Sub
The only difference is the _Change and the _Scroll portion.

Hopefully that helps.
 
Thanks for the suggestion, Jim. It turns out there was a separate erro
causing my problems.

I love it when that happens...

Morgan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top