andrewvanmarle
New Member
- Joined
- Aug 11, 2015
- Messages
- 40
Hi Everyone, I'm Andrew, and new here. (and I have a question of course)
I made a lovely feature for our invoices, a userform that calculated a fee by percentage
courtage is a field where apercentage is enetered (for instance 1.5) and koopsom is the field where a large amount (lets say 500,000) is entered
I run the following code :
here is the strange thing that happens if I enter a whole number in courtage then the calculatioon works, but if I enter for instance 1.2, then the result is ten times too large. If I enter 1.22 the result is 100 times too large etc.
It seems the code does something wierd with the decimal point when calculating. Can anyone see what is wrong?
I made a lovely feature for our invoices, a userform that calculated a fee by percentage
courtage is a field where apercentage is enetered (for instance 1.5) and koopsom is the field where a large amount (lets say 500,000) is entered
I run the following code :
Code:
Private Sub koopsom_Change() If koopsom = vbNullString Then Exit Sub
If Not IsNumeric(TextBox1) Then
MsgBox "alleen getallen"
koopsom = vbNullString
End If
koopsom.Value = Format(koopsom.Value, "#,###,##")
End Sub
Private Sub invoerButton1_Click()
bedrag = (courtage / 1000) * koopsom
ActiveSheet.Range("E20").Value = bedrag.Value
ActiveSheet.Range("D20").Value = "Courtage conform afspraak à " & courtage.Value & " %"
ActiveSheet.Range("B20").Value = 1
End Sub
here is the strange thing that happens if I enter a whole number in courtage then the calculatioon works, but if I enter for instance 1.2, then the result is ten times too large. If I enter 1.22 the result is 100 times too large etc.
It seems the code does something wierd with the decimal point when calculating. Can anyone see what is wrong?