Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 183
  • Last Modified:

Calculating Without A Command Button

I was wondering how I can calculate a product of 3 text boxes to a 4th text box without a command button.  I want to multiply Principle * Rate * Time to = Interest without a button you have to click to see the answer.  I am using scroll bars so the number changes when you hit the scroll bar and I want my interest to show up and change also when another thing is changed.  My code is I copied below.  I need to know how to make the product show up without a button.  Please help.  Thank you!

Private Sub hscrPrinciple_Change()
    txtPrinciple.Text = CStr(hscrPrinciple.Value)
End Sub

Private Sub hscrRate_Change()
    txtRate.Text = CStr(hscrRate.Value)
End Sub

Private Sub hscrTime_Change()
    txtTime.Text = CStr(hscrTime.Value)
End Sub

Private Sub txtInterest_Change()
End Sub

Private Sub txtPrinciple_Change()
End Sub

Private Sub txtRate_Change()
End Sub

Private Sub txtTime_Change()
End Sub
0
moonglade
Asked:
moonglade
1 Solution
 
ericl1stCommented:
Try this:

Private Sub hscrPrinciple_Change()
   txtPrinciple.Text = CStr(hscrPrinciple.Value)
End Sub

Private Sub hscrRate_Change()
   txtRate.Text = CStr(hscrRate.Value)
End Sub

Private Sub hscrTime_Change()
   txtTime.Text = CStr(hscrTime.Value)
End Sub

Private Sub txtInterest_Change()
End Sub

Private Sub txtPrinciple_Change()
   txtInterest.Text = txtPrinciple.Text * txtRate.Text * txtTime.Text
End Sub

Private Sub txtRate_Change()
   txtInterest.Text = txtPrinciple.Text * txtRate.Text * txtTime.Text
End Sub

Private Sub txtTime_Change()
   txtInterest.Text = txtPrinciple.Text * txtRate.Text * txtTime.Text
End Sub
0
 
MN_DaveCommented:
You could create a function that multiplies the values from the three text boxes and returns the result.  You could then call this function after the assignment in each of your scroll change events....

Private Sub hscrPrinciple_Change()
   txtPrinciple.Text = CStr(hscrPrinciple.Value)
   txtInterest.Text = calc_Interest()
End Sub

Private Sub hscrRate_Change()
   txtRate.Text = CStr(hscrRate.Value)
   txtInterest.Text = calc_Interest()
End Sub

Private Sub hscrTime_Change()
   txtTime.Text = CStr(hscrTime.Value)
   txtInterest.Text = calc_Interest()
End Sub

Private Function calc_Interest() as Single
  code to multiply values and return result goes here...
End Function
0
 
JacamarCommented:
Well, depending on your exact needs, in each of the change functions you could call a funtion that would ensure that all fields were filled in, and if so, would execute your calculation.  This is a type of real-time procedure that is usually very pleasant to use.  If you want to try this way, I will provide some code.
0
 
moongladeAuthor Commented:
Code worked great!!!  Thanks sooo much!
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now