http://www.mediafire.com/?sxzle6zvjm9urat
Código
Public Class Form1 Dim resultado As Double Dim b As Boolean Dim primerNumero As Double Dim segundoNumero As Double Dim cont As Short = 0 'NUMEROS Y COMA Private Sub Btn0_Click(sender As System.Object, e As System.EventArgs) Handles Btn0.Click TextBox1.Text = TextBox1.Text & 0 End Sub Private Sub Btn1_Click(sender As System.Object, e As System.EventArgs) Handles Btn1.Click TextBox1.Text = TextBox1.Text & 1 End Sub Private Sub Btn2_Click(sender As System.Object, e As System.EventArgs) Handles Btn2.Click TextBox1.Text = TextBox1.Text & 2 End Sub Private Sub Btn3_Click(sender As System.Object, e As System.EventArgs) Handles Btn3.Click TextBox1.Text = TextBox1.Text & 3 End Sub Private Sub Btn4_Click(sender As System.Object, e As System.EventArgs) Handles Btn4.Click TextBox1.Text = TextBox1.Text & 4 End Sub Private Sub Btn5_Click(sender As System.Object, e As System.EventArgs) Handles Btn5.Click TextBox1.Text = TextBox1.Text & 5 End Sub Private Sub Btn6_Click(sender As System.Object, e As System.EventArgs) Handles Btn6.Click TextBox1.Text = TextBox1.Text & 6 End Sub Private Sub Btn7_Click(sender As System.Object, e As System.EventArgs) Handles Btn7.Click TextBox1.Text = TextBox1.Text & 7 End Sub Private Sub Btn8_Click(sender As System.Object, e As System.EventArgs) Handles Btn8.Click TextBox1.Text = TextBox1.Text & 8 End Sub Private Sub Btn9_Click(sender As System.Object, e As System.EventArgs) Handles Btn9.Click TextBox1.Text = TextBox1.Text & 9 End Sub Private Sub BtnComa_Click(sender As System.Object, e As System.EventArgs) Handles BtnComa.Click TextBox1.Text = TextBox1.Text & "," End Sub 'FUNCIÓN QUE RECORRA CADA VEZ QUE SE AÑADA UN Nº EN EL TEXTBOX EN BUSCA DE COMAS Y CUENTE SI YA HAY 1 PARA QUE NO PERMITA PONER MAS, POR EJEMPLO DESHABILITANDO EL BOTÓN O INFORMANDOLO MSGBOX 'OPERACIONES Private Sub BtnMas_Click(sender As System.Object, e As System.EventArgs) Handles BtnMas.Click cont = cont + 1 Call Operar(TextBox1.Text, BtnMas.Text) End Sub Private Sub BtnMenos_Click(sender As System.Object, e As System.EventArgs) Handles BtnMenos.Click cont = cont + 1 Call Operar(TextBox1.Text, BtnMenos.Text) End Sub Private Sub BtnMultiplicar_Click(sender As System.Object, e As System.EventArgs) Handles BtnMultiplicar.Click cont = cont + 1 Call Operar(TextBox1.Text, BtnMultiplicar.Text) End Sub Private Sub BtnDividir_Click(sender As System.Object, e As System.EventArgs) Handles BtnDividir.Click cont = cont + 1 Call Operar(TextBox1.Text, BtnDividir.Text) End Sub Private Sub BtnIgual_Click(sender As System.Object, e As System.EventArgs) Handles BtnIgual.Click cont = cont + 1 If cont = 1 Then TextBox2.Text = primerNumero End If If cont = 2 Then TextBox2.Text = TextBox2.Text & TextBox1.Text & " = " & resultado End If If cont > 2 Then TextBox2.Text = TextBox2.Text & TextBox1.Text & " = " & resultado End If End Sub Private Sub Operar(ByVal numero As Double, ByVal operando As String) Select Case cont Case 1 Select Case operando Case "+" primerNumero = numero TextBox2.Text = primerNumero & operando Case "-" primerNumero = numero Case "X" primerNumero = numero Case "/" primerNumero = numero End Select TextBox1.Text = "" Case 2 Select Case operando Case "+" TextBox2.Text = TextBox2.Text & numero & operando resultado = primerNumero + numero Case "-" resultado = primerNumero * numero Case "X" resultado = primerNumero * numero Case "/" resultado = primerNumero / numero End Select 'TextBox2.Text = resultado TextBox1.Text = "" Case Else Select Case operando Case "+" TextBox2.Text = TextBox2.Text & numero & operando resultado = resultado + numero Case "-" resultado = resultado - numero Case "X" resultado = resultado * numero Case "/" resultado = resultado / numero End Select TextBox1.Text = "" End Select End Sub End Class