?
Solved

Calculating Without A Command Button

Posted on 2003-03-22
4
Medium Priority
?
182 Views
Last Modified: 2010-05-01
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
Comment
Question by:moonglade
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 1

Accepted Solution

by:
ericl1st earned 700 total points
ID: 8188818
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
 
LVL 1

Expert Comment

by:MN_Dave
ID: 8188821
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
 
LVL 2

Expert Comment

by:Jacamar
ID: 8188870
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
 

Author Comment

by:moonglade
ID: 8188876
Code worked great!!!  Thanks sooo much!
0

Featured Post

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

752 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