27/09/14 15:25
WCodeLyokoYT
Sto creando una calcolatrice in VB.Net e come da titolo non riesco ad inserire il punto(o la virgola) nelle variabili Valore1 e Valore2.
Allego il codice:
Allego il codice:
Public Class Form1 Dim Valore1 As Double Dim Valore2 As Double Dim Totale As Double Dim Op As String Dim Val2 As Boolean #Region "Numeri" Private Sub Button17_Click(sender As Object, e As EventArgs) Handles Button17.Click If Val2 = 0 Then Valore1 = Valore1 & "1" RichTextBox1.Text = Valore1 Else Valore2 = Valore2 & "1" RichTextBox1.Text = Valore2 End If End Sub Private Sub Button18_Click(sender As Object, e As EventArgs) Handles Button18.Click If Val2 = 0 Then Valore1 = Valore1 & "2" RichTextBox1.Text = Valore1 Else Valore2 = Valore2 & "2" RichTextBox1.Text = Valore2 End If End Sub Private Sub Button19_Click(sender As Object, e As EventArgs) Handles Button19.Click If Val2 = 0 Then Valore1 = Valore1 & "3" RichTextBox1.Text = Valore1 Else Valore2 = Valore2 & "3" RichTextBox1.Text = Valore2 End If End Sub Private Sub Button20_Click(sender As Object, e As EventArgs) Handles Button20.Click If Val2 = 0 Then Valore1 = Valore1 & "4" RichTextBox1.Text = Valore1 Else Valore2 = Valore2 & "4" RichTextBox1.Text = Valore2 End If End Sub Private Sub Button21_Click(sender As Object, e As EventArgs) Handles Button21.Click If Val2 = 0 Then Valore1 = Valore1 & "5" RichTextBox1.Text = Valore1 Else Valore2 = Valore2 & "5" RichTextBox1.Text = Valore2 End If End Sub Private Sub Button22_Click(sender As Object, e As EventArgs) Handles Button22.Click If Val2 = 0 Then Valore1 = Valore1 & "6" RichTextBox1.Text = Valore1 Else Valore2 = Valore2 & "6" RichTextBox1.Text = Valore2 End If End Sub Private Sub Button23_Click(sender As Object, e As EventArgs) Handles Button23.Click If Val2 = 0 Then Valore1 = Valore1 & "7" RichTextBox1.Text = Valore1 Else Valore2 = Valore2 & "7" RichTextBox1.Text = Valore2 End If End Sub Private Sub Button24_Click(sender As Object, e As EventArgs) Handles Button24.Click If Val2 = 0 Then Valore1 = Valore1 & "8" RichTextBox1.Text = Valore1 Else Valore2 = Valore2 & "8" RichTextBox1.Text = Valore2 End If End Sub Private Sub Button25_Click(sender As Object, e As EventArgs) Handles Button25.Click If Val2 = 0 Then Valore1 = Valore1 & "9" RichTextBox1.Text = Valore1 Else Valore2 = Valore2 & "9" RichTextBox1.Text = Valore2 End If End Sub Private Sub Button11_Click(sender As Object, e As EventArgs) Handles Button11.Click If Val2 = 0 Then Valore1 = Valore1 & "," RichTextBox1.Text = Valore1 Else Valore2 = Valore2 & "," RichTextBox1.Text = Valore2 End If End Sub Private Sub Button10_Click(sender As Object, e As EventArgs) Handles Button10.Click If Val2 = 0 Then Valore1 = Valore1 & "0" RichTextBox1.Text = Valore1 Else Valore2 = Valore2 & "0" RichTextBox1.Text = Valore2 End If End Sub #End Region #Region "Operazioni" Private Sub Button26_Click(sender As Object, e As EventArgs) Handles Button26.Click Op = "+" Val2 = 1 RichTextBox1.Text = "0" End Sub Private Sub Button27_Click(sender As Object, e As EventArgs) Handles Button27.Click Op = "-" Val2 = 1 RichTextBox1.Text = "0" End Sub Private Sub Button15_Click(sender As Object, e As EventArgs) Handles Button15.Click Op = "*" Val2 = 1 RichTextBox1.Text = "0" End Sub Private Sub Button16_Click(sender As Object, e As EventArgs) Handles Button16.Click Op = "/" Val2 = 1 RichTextBox1.Text = "0" End Sub #End Region Private Sub Button12_Click(sender As Object, e As EventArgs) Handles Button12.Click If Op <> "" Then If Op = "+" Then Totale = Valore1 + Valore2 End If If Op = "-" Then Totale = Valore1 - Valore2 End If If Op = "*" Then Totale = Valore1 * Valore2 End If If Op = "/" Then Totale = Valore1 / Valore2 End If RichTextBox1.Text = Totale Valore1 = "0" Valore2 = "0" Val2 = 0 Op = 0 End If End Sub End Class
aaa