Issues with forms

Juliame9

New Member
Joined
Jan 10, 2018
Messages
12
Hi,

This forum has been very helpful so far so I'm hoping you can help me solve a few issues I have.

1. The form has three text boxes for inputs and a label where I'm calculating monthly payment based on the inputs.
- I would like to format the result in the label in this format "#,###", and when I used a text box for the result I had no problem using this code:
Private Sub Payoff_Change() Payoff.Value = Format(Payoff.Value, "#,###")
End Sub
but it's not working using a label. Any ideas how I can do this?
- I would like the result to be calculated without using a command button. just when the user finishes the inputs, I want the calculation to show in the label. I tried using MouseMove but when I move the mouse before finishing to input, it gives me an error.

2. I have another three text boxes and a label which calculates their sum. The issue is that the text boxes are formatted in this format "#,###" and when I sum them it only sums the digits before the first comma. so for example, if I have 2,900 3,400 and 1,500 it will sum 2+3+1 = 6
This is the code I'm using to sum them:
Fixed = Val(TxtService.Text) + Val(TxtLabor.Text) + Val(TxtUtil.Text)
Any Ideas here?

I think this is it for now... any help would be much appreciated!
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Re #1 , you can format the result immediately after calculating it and then assign that to the label's caption.
Re #2 use CLng rather than Val, assuming they are integers (use CDbl if not)
 
Upvote 0
Try ,


1) Label doesn’t has value property, try caption


Code:
Private Sub Payoff_Change()
    Payoff.Caption = Format(Payoff.Caption, "#,###")
End Sub




2) Use CdLb function for decimal level sum


Code:
Fixed = CDbl(TxtService.Text) + CDbl(TxtLabor.Text) + CDbl(TxtUtil.Text)
 
Upvote 0
Thank you guys, the second issue is solved!

However the formatting still doesn't work.. and I still couldn't find any solution to calculation without using a command button. Any ideas there?
 
Upvote 0
You haven't really given us a lot to go on! You should have a routine that is called after updating each of the three textboxes (Perhaps using their Exit events) to calculate the number and assign it to the label.
 
Upvote 0

Forum statistics

Threads
1,215,256
Messages
6,123,903
Members
449,132
Latest member
Rosie14

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top