03-12-2012, 12:02 PM
Hello, BP community.
Well, I made a calculator in VB10, but there is a problem. The "." button shows the wrong results. For example, 12.5 + 12.5 = 24,5.
The code snippet I use for the dot button is this one:
And the code snippet I use for calculating is this:
I gave you those two codes because you maybe need the calculating code, as well, to edit it for me. Maybe you need an explanation with that "x" variable. It actually prevents "." to be in one text box twice.
I have no idea if you understood the x variable, but it is not actually so important (for you). I hope I get response soon. Thanks.
Regards,
Vinwarez.
Well, I made a calculator in VB10, but there is a problem. The "." button shows the wrong results. For example, 12.5 + 12.5 = 24,5.
The code snippet I use for the dot button is this one:
Code:
x = x + 1
If x = 1 Then
txtMain.AppendText(".")
Else
'Do Nothing
End If
And the code snippet I use for calculating is this:
Code:
Try
If Operation = "+" Then
Answer = Number + Val(txtMain.Text)
History.Items.Add(Number + " + " + txtMain.Text + " = " + Answer)
txtMain.Clear()
txtMain.Text = Answer
x = 0
ElseIf Operation = "-" Then
Answer = Number - Val(txtMain.Text)
History.Items.Add(Number + " - " + txtMain.Text + " = " + Answer)
txtMain.Clear()
txtMain.Text = Answer
x = 0
ElseIf Operation = "*" Then
Answer = Number * Val(txtMain.Text)
History.Items.Add(Number + " * " + txtMain.Text + " = " + Answer)
txtMain.Clear()
txtMain.Text = Answer
x = 0
ElseIf Operation = "/" Then
Answer = Number / Val(txtMain.Text)
History.Items.Add(Number + " / " + txtMain.Text + " = " + Answer)
txtMain.Clear()
txtMain.Text = Answer
x = 0
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
I gave you those two codes because you maybe need the calculating code, as well, to edit it for me. Maybe you need an explanation with that "x" variable. It actually prevents "." to be in one text box twice.
I have no idea if you understood the x variable, but it is not actually so important (for you). I hope I get response soon. Thanks.
Regards,
Vinwarez.
Also known as Rocketalypse.
System.out.println("I prefer Java.");
System.out.println("I prefer Java.");