Public Class Form1
Dim nombreB As String = ""
Public Sub ControlSetFocus(ByVal control As Control)
' Set focus to the control, if it can receive focus.
If control.CanFocus Then
control.Focus()
End If
End Sub
Private Sub btnBorrar(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button13.Click
Dim resultado
Dim borrar = txtPantalla.Text.Length - 1
resultado = txtPantalla.Text.Substring(0, borrar)
txtPantalla.Text = resultado
txtPantalla.Focus()
Dim Posicion = txtPantalla.Text.Length
txtPantalla.SelectionStart = Posicion
End Sub
Private Sub btnDos_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim Cars() As String = {"a", "b", "c", "2"}
Static I As Integer = 0
Dim ObjButton As Button = CType(sender, Button)
If I >= Cars.Length Then
I = 0
End If
If nombreB <> ObjButton.Text Then
I = 0
nombreB = ObjButton.Text
Else
txtPantalla.Text = Mid(txtPantalla.Text, 1, Len(txtPantalla.Text) - 1)
End If
txtPantalla.Text = txtPantalla.Text & Cars(I)
I = I + 1
'Funcion MID
'If txtPantalla.Text Then
'txtPantalla.Text = Mid(txtPantalla.Text, 1, Len(txtPantalla.Text) - 1)
'End If
Dim Posicion = txtPantalla.Text.Length
txtPantalla.Focus()
txtPantalla.SelectionStart = Posicion
End Sub
Private Sub btnTres_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim Cars() As String = {"d", "e", "f", "3"}
Static I As Integer = 0
Dim ObjButton As Button = CType(sender, Button)
If I >= Cars.Length Then
I = 0
End If
If nombreB <> ObjButton.Text Then
I = 0
nombreB = ObjButton.Text
Else
txtPantalla.Text = Mid(txtPantalla.Text, 1, Len(txtPantalla.Text) - 1)
End If
txtPantalla.Text = txtPantalla.Text & Cars(I)
I = I + 1
txtPantalla.Focus()
Dim Posicion = txtPantalla.Text.Length
txtPantalla.SelectionStart = Posicion
End Sub
Private Sub btnCuatro_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Dim Cars() As String = {"g", "h", "i", "4"}
Static I As Integer = 0
Dim ObjButton As Button = CType(sender, Button)
If I >= Cars.Length Then
I = 0
End If
If nombreB <> ObjButton.Text Then
I = 0
nombreB = ObjButton.Text
Else
txtPantalla.Text = Mid(txtPantalla.Text, 1, Len(txtPantalla.Text) - 1)
End If
txtPantalla.Text = txtPantalla.Text & Cars(I)
I = I + 1
txtPantalla.Focus()
Dim Posicion = txtPantalla.Text.Length
txtPantalla.SelectionStart = Posicion
End Sub
Private Sub btnCinco_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Dim Cars() As String = {"j", "k", "l", "5"}
Static I As Integer = 0
Dim ObjButton As Button = CType(sender, Button)
If I >= Cars.Length Then
I = 0
End If
If nombreB <> ObjButton.Text Then
I = 0
nombreB = ObjButton.Text
Else
txtPantalla.Text = Mid(txtPantalla.Text, 1, Len(txtPantalla.Text) - 1)
End If
txtPantalla.Text = txtPantalla.Text & Cars(I)
I = I + 1
txtPantalla.Focus()
Dim Posicion = txtPantalla.Text.Length
txtPantalla.SelectionStart = Posicion
End Sub
Private Sub btnSeis_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
Dim Cars() As String = {"m", "n", "o", "6"}
Static I As Integer = 0
Dim ObjButton As Button = CType(sender, Button)
If I >= Cars.Length Then
I = 0
End If
If nombreB <> ObjButton.Text Then
I = 0
nombreB = ObjButton.Text
Else
txtPantalla.Text = Mid(txtPantalla.Text, 1, Len(txtPantalla.Text) - 1)
End If
txtPantalla.Text = txtPantalla.Text & Cars(I)
I = I + 1
txtPantalla.Focus()
Dim Posicion = txtPantalla.Text.Length
txtPantalla.SelectionStart = Posicion
End Sub
Private Sub btnSiete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
Dim Cars() As String = {"p", "q", "r", "s", "7"}
Static I As Integer = 0
Dim ObjButton As Button = CType(sender, Button)
If I >= Cars.Length Then
I = 0
End If
If nombreB <> ObjButton.Text Then
I = 0
nombreB = ObjButton.Text
Else
txtPantalla.Text = Mid(txtPantalla.Text, 1, Len(txtPantalla.Text) - 1)
End If
txtPantalla.Text = txtPantalla.Text & Cars(I)
I = I + 1
txtPantalla.Focus()
Dim Posicion = txtPantalla.Text.Length
txtPantalla.SelectionStart = Posicion
End Sub
Private Sub btnOcho_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
Dim Cars() As String = {"t", "u", "v", "8"}
Static I As Integer = 0
Dim ObjButton As Button = CType(sender, Button)
If I >= Cars.Length Then
I = 0
End If
If nombreB <> ObjButton.Text Then
I = 0
nombreB = ObjButton.Text
Else
txtPantalla.Text = Mid(txtPantalla.Text, 1, Len(txtPantalla.Text) - 1)
End If
txtPantalla.Text = txtPantalla.Text & Cars(I)
I = I + 1
txtPantalla.Focus()
Dim Posicion = txtPantalla.Text.Length
txtPantalla.SelectionStart = Posicion
End Sub
Private Sub btnNueve_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
Dim Cars() As String = {"w", "x", "y", "z", "9"}
Static I As Integer = 0
Dim ObjButton As Button = CType(sender, Button)
If I >= Cars.Length Then
I = 0
End If
If nombreB <> ObjButton.Text Then
I = 0
nombreB = ObjButton.Text
Else
txtPantalla.Text = Mid(txtPantalla.Text, 1, Len(txtPantalla.Text) - 1)
End If
txtPantalla.Text = txtPantalla.Text & Cars(I)
I = I + 1
txtPantalla.Focus()
Dim Posicion = txtPantalla.Text.Length
txtPantalla.SelectionStart = Posicion
End Sub
End Class