TessieBear99
New Member
- Joined
- Aug 26, 2018
- Messages
- 20
- Office Version
- 365
- Platform
- Windows
Hi all,
I've created a UserForm calculator to remove the tax component from a value (I've posted about this once previously) but I've just struck an issue - it's working perfectly in calculating numbers based off a value up to and including 999.99, but anything 1000 and over it's not working.
The calculation is finding x in "x+10%=y" with y being the number I enter in the first box. So in the first picture below you can see that the second box plus 10% equals the first box, however in the second picture it's clearly wrong.
This is my code:
Any assistance and an explanation would be greatly appreciated
Thanks
Tess
I've created a UserForm calculator to remove the tax component from a value (I've posted about this once previously) but I've just struck an issue - it's working perfectly in calculating numbers based off a value up to and including 999.99, but anything 1000 and over it's not working.
The calculation is finding x in "x+10%=y" with y being the number I enter in the first box. So in the first picture below you can see that the second box plus 10% equals the first box, however in the second picture it's clearly wrong.
This is my code:
VBA Code:
Option Explicit
Private Sub cmdClear_Click()
' Clicking the Clear button resets the text boxes
txtCalc = ""
txtEntry = ""
End Sub
Private Sub cmdCalc_Click()
' Clicking the = button completes the calculation based off text box 1 (txtEntry) and returns the value in text box 2 (txtCalc)
Dim total As Currency
Dim GST As Double
GST = Val(txtEntry.Value) / 11
total = GST * 10
txtCalc = total
End Sub
Private Sub cmdClose_Click()
' Clicking the Close button closes the window
Unload Me
End Sub
Private Sub cmdCopy_Click()
' Clicking the Copy button copies the value in text box 2 (txtCalc) to the clipboard
With Me.txtCalc
.SelStart = 0
.SelLength = Len(.Text)
.Copy
End With
End Sub
Private Sub txtCalc_Change()
' Formats the value in text box 2 (txtCalc) once it has been populated
Me.txtCalc = Format(Me.txtCalc, "#,##0.00##")
End Sub
Private Sub txtEntry_AfterUpdate()
'Formats the value in text box 1 (txtEntry) once it has been entered
Me.txtEntry = Format(Me.txtEntry, "#,##0.00")
End Sub
Any assistance and an explanation would be greatly appreciated
Thanks
Tess