TessieBear99
New Member
- Joined
- Aug 26, 2018
- Messages
- 20
- Office Version
- 365
- Platform
- Windows
Hi all,
I've made a small basic calculator simply to subtract the GST component from a GST-inclusive number (for those who aren't Australian, GST is Goods & Services Tax which is a 10% tax on certain items sold, so I have the Y and I'm trying to find the X in "X+10%=Y").
I have the calculation which is the GST incl. number divided by 11 and multiplied by 10 (e.g. 100/11 = 9.09 * 10 = 90.91) and I think this is working because it gives me a partially accurate result but the decimals aren't working, at least I think this is my issue. I will put 100 in the entry box and click = and it will spit out 90.00 (which we know is wrong, but close).
I've formatted the textboxes so when they're updated they become "#,##0.00".
Object names are...
UserForm name: frmGSTCalc
First text box name: txtEntry
Second text box name: txtCalc
" = " button name: cmdCalc
Here's my code:
Here's what it looks like:
Any help would be greatly appreciated!
Thanks
I've made a small basic calculator simply to subtract the GST component from a GST-inclusive number (for those who aren't Australian, GST is Goods & Services Tax which is a 10% tax on certain items sold, so I have the Y and I'm trying to find the X in "X+10%=Y").
I have the calculation which is the GST incl. number divided by 11 and multiplied by 10 (e.g. 100/11 = 9.09 * 10 = 90.91) and I think this is working because it gives me a partially accurate result but the decimals aren't working, at least I think this is my issue. I will put 100 in the entry box and click = and it will spit out 90.00 (which we know is wrong, but close).
I've formatted the textboxes so when they're updated they become "#,##0.00".
Object names are...
UserForm name: frmGSTCalc
First text box name: txtEntry
Second text box name: txtCalc
" = " button name: cmdCalc
Here's my code:
VBA Code:
Private Sub cmdCalc_Click()
Dim total As Long
Dim GST As Long
GST = Val(txtEntry.Value) / 11
total = GST * 10
txtCalc = total
End Sub
Private Sub txtCalc_Change()
Me.txtCalc = Format(Me.txtCalc, "#,##0.00")
End Sub
Private Sub txtEntry_AfterUpdate()
Me.txtEntry = Format(Me.txtEntry, "#,##0.00")
End Sub
Here's what it looks like:
Any help would be greatly appreciated!
Thanks