lunes, 14 de junio de 2010

Código Fuente Clase 14-06-2010

Public Class Form1

    'Declaro a nivel global los vectores para:

    'nombre, tipo iva, y la CUIT

    Dim Nom() As String

    Dim tipoiva() As String

    Dim cuit() As Double

 

    '''''''''''''''''''''''''''''''''''''''''''

 

 

 

    Sub LimpiarUnTexBox(ByRef txt As TextBox)

        txt.Text = ""

    End Sub

 

 

 

    Private Sub Combo1_SelectedIndexChanged(ByVal sender As System.Object, _

                                            ByVal e As System.EventArgs) Handles Combo1.SelectedIndexChanged

 

        If Combo1.Text = "Consumidor Final" Then

            LimpiarUnTexBox(Text1)

            Text1.Enabled = False

            Text1.BackColor = Color.Silver

 

            LimpiarUnTexBox(Text2)

            Text2.Text = ""

            Text2.Enabled = False

            Text2.BackColor = Color.Silver

 

            LimpiarUnTexBox(Text3)

            Text3.Text = ""

            Text3.Enabled = False

            Text3.BackColor = Color.Silver

 

        Else

            Text1.Enabled = True

            Text1.BackColor = Color.White

 

            Text2.Enabled = True

            Text2.BackColor = Color.White

 

            Text3.Enabled = True

            Text3.BackColor = Color.White

 

        End If

 

    End Sub

 

 

 

 

 

 

    Private Sub Text1_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Text1.KeyPress

        If Asc(e.KeyChar) = 8 Then 'controlo si ha ingresado el BackSpace (codigo Ascii N°8)

            Exit Sub

        End If

 

        Dim auxIntAscciCode = Asc(e.KeyChar)

 

        If Not (auxIntAscciCode >= CInt(System.Windows.Forms.Keys.D0) _

                AndAlso auxIntAscciCode <= CInt(System.Windows.Forms.Keys.D9)) Then

            'cambio el valor de la letra, por vacío

            e.KeyChar = ""

        End If

 

    End Sub

 

    'Item 5 del ejercicio (al presionar Enter en "Texto"...)

    Private Sub Texto_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Texto.KeyPress

        If Asc(e.KeyChar) = 13 Then

            Combo1.Focus()

        End If

    End Sub

 

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        'Validar

        If String.IsNullOrEmpty(Texto.Text.Trim) Then

            MsgBox("Debe Ingresar un nombre")

            Texto.Focus()

            Exit Sub

        End If

 

        If Combo1.Text <> "Consumidor Final" Then

            'Verifico que haya ingresado el IVA

            If String.IsNullOrEmpty(Text1.Text.Trim) Then

                MsgBox("Debe Ingresar El primer dígito de la CUIL")

                Text1.Focus()

                Exit Sub

            End If

 

            If String.IsNullOrEmpty(Text2.Text.Trim) Then

                MsgBox("Debe Ingresar El segundo dígito de la CUIL")

                Text2.Focus()

                Exit Sub

            End If

 

 

            If String.IsNullOrEmpty(Text3.Text.Trim) Then

                MsgBox("Debe Ingresar El Tercer dígito de la CUIL")

                Text3.Focus()

                Exit Sub

            End If

        End If

 

 

 

    End Sub

End Class

 

No hay comentarios:

Publicar un comentario