ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VBA Code and Checkboxes (https://www.excelbanter.com/excel-programming/383509-vba-code-checkboxes.html)

Gimp

VBA Code and Checkboxes
 
I have a checkbox on a user form that when checked adds $30.00 to the
value in a textbox. What I want to do is add more code that takes the
$30.00 away or subtracts it. Say for example the user hits the
checkbox and realizes that this was an error, then unchecks the
box....I want that $30.00 that was added when it was first checked to
be removed or subtracted once it's unchecked...here is my code so far:


If CheckBox1.Value = True Then
TextBox32.Value = CDbl(TextBox32.Text) + 30
End If
TextBox32.Text = Format(TextBox32.Text, "currency")


This is in the checkbox sub.

So is there a 'changes to' type function that can be used?


Gimp

VBA Code and Checkboxes
 
On Feb 19, 11:06 am, "Gimp" wrote:
I have a checkbox on a user form that when checked adds $30.00 to the
value in a textbox. What I want to do is add more code that takes the
$30.00 away or subtracts it. Say for example the user hits the
checkbox and realizes that this was an error, then unchecks the
box....I want that $30.00 that was added when it was first checked to
be removed or subtracted once it's unchecked...here is my code so far:

If CheckBox1.Value = True Then
TextBox32.Value = CDbl(TextBox32.Text) + 30
End If
TextBox32.Text = Format(TextBox32.Text, "currency")

This is in the checkbox sub.

So is there a 'changes to' type function that can be used?


Wait...I just got this to work...thanks to anyone who was going to
respond....!!!

I just added a 'false' statement after the above code and it behaves
like a toggle switch....



All times are GMT +1. The time now is 09:14 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com