La razón de ser

La vuelta a la Patria es un compromiso...la responsabilidad social...el aporte generoso...el modelo...la vida misma.

Parte 04 Aprendiendo Visual Basic 2010 Express

22 de Abril de 2012

Ejercicio Nº 17 (Manejo de Propiedades)

Generar un formulario para colocar secuencialmente el label en cada vértice del formulario, con cambios de alineación, estilo, font y color, contenido y apariencia del label, considerando que a cada cambio de tamaño del formulario -en ejecución- se coloque el label en el vértice superior derecho.





Public Class Form1

    Private TIPO_LETRA As String = "WIDE LATIN"
    Private mYFontBold As New Font(TIPO_LETRA, 14, FontStyle.Bold)

    Dim POS_X = 0
    Dim POS_Y = 0

    Dim VERTICE As String = "SI" 'VERTICE SUPERIOR IZQUIERDO


    Private Sub Label1_Click(ByVal sender As System.Object, ByVal e _
                             As System.EventArgs) Handles Label1.Click

        Label1.Font = mYFontBold

        Label1.Font = New Font(TIPO_LETRA, 14, FontStyle.Bold)
        Label1.Location = New Point(POS_X, POS_Y)


        Label2.Text = Me.Width
        Label3.Text = Me.ClientRectangle.Width
        Label4.Text = Me.ClientSize.Width

        If Label1.Text = "HOLA" Then
            Label1.Text = "MI AMOR"

        Else
            Label1.Text = "HOLA"
        End If

        If Label1.TextAlign = 32 Then
            Label1.TextAlign = 2
        Else
            Label1.TextAlign = 32
        End If

        If Label1.BorderStyle = 2 Then
            Label1.BorderStyle = 1
        Else
            Label1.BorderStyle = 2
        End If

        If Label1.ForeColor = Color.Red Then
            Label1.ForeColor = Color.Black
        Else
            Label1.ForeColor = Color.Red
        End If

        If TIPO_LETRA = "MICROSOFT SANS SERIF" Then
            TIPO_LETRA = "WIDE LATIN"
        Else
            TIPO_LETRA = "MICROSOFT SANS SERIF"
        End If

        Select Case VERTICE
            Case Is = "SI" 'VERTICE SUPERIOR IZQUIERDO
                POS_X = Me.ClientSize.Width - Label1.Width
                POS_Y = 0
                VERTICE = "SD" 'SUPERIOR DERECHO

            Case Is = "SD"

                POS_X = Me.ClientSize.Width - Label1.Width
                POS_Y = Me.ClientSize.Height - Label1.Height
                VERTICE = "ID" 'INFERIOR DERECHO

            Case Is = "ID"

                POS_X = 0
                POS_Y = Me.ClientSize.Height - Label1.Height
                VERTICE = "II" 'INFERIOR IZQUIERDO

            Case Is = "II"
                POS_X = 0
                POS_Y = 0
                VERTICE = "SI" 'SUPERIOR IZQUIERDO

        End Select
    End Sub

    Private Sub Form1_Resize(ByVal sender As System.Object, ByVal e As  _
                             System.EventArgs) Handles MyBase.Resize

        POS_X = 0
        POS_Y = 0

        Label1.Location = New Point(POS_X, POS_Y)

        POS_X = Me.ClientSize.Width - Label1.Width
        POS_Y = 0
        VERTICE = "SD" 'SUPERIOR DERECHO

    End Sub

End Class

Sugerencias

Para el módulo de código




Hacer click con el botón derecho en el formulario para activar las propiedades, luego click en eventos y luego doble click en Resize, para escribir el código asociado al evento










Ejercicio Nº  18 (Animación)

Generar un programa para poner a "girar" una pelota más o menos rápido según requerimientos

Pasos:

1. Crear ocho imágenes en distintas posiciones y guardarlas en archivos JEPG pelota_1,
    pelota_2, pelota_3, etc. (puede usar PowerPoint)


2. Guardarlas en el directorio de recursos
    Utlizar propiedades de Form1 + BackgroundImage + Importar










3. Crear un formulario con:
    1 Picture box
    1 Label
    3 Botones

4. Colocar en el Picturebox la imagen pelota_1con propiedades

5. Insertar el código

Public Class Form1
    Dim LAPSO As Double = 0.1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As  _
                              System.EventArgs) Handles Button1.Click
        'Decremento de del tiempo de giro
        Label1.Text = "A toda máquina"

        If LAPSO - 0.01 < 0.01 Then
            Label1.Text = "No puedo más"
        Else
            LAPSO = LAPSO - 0.01
        End If

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e _
                              As System.EventArgs) Handles Button2.Click
        Label1.Text = "Descansando"
        'Incremento del tiempo de gito
        If LAPSO + 0.01 = 0.1 Then
            Label1.Text = "Muy lento"
        Else
            LAPSO = LAPSO + 0.01
        End If

    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e _
                              As System.EventArgs) Handles Button3.Click

        Label1.Text = "Suavecito"
        'Repetición perenne
        Do While True

            With PictureBox1
                .Image = WindowsApplication1.My.Resources.Resources.pelota_1
            End With

            'Generación de pausa
            Pausa(LAPSO)

            With PictureBox1
                .Image = WindowsApplication1.My.Resources.Resources.pelota_2
            End With

            Pausa(LAPSO)

            With PictureBox1
                .Image = WindowsApplication1.My.Resources.Resources.pelota_3
            End With

            Pausa(LAPSO)

            With PictureBox1
                .Image = WindowsApplication1.My.Resources.Resources.pelota_4
            End With

            Pausa(LAPSO)

            With PictureBox1
                .Image = WindowsApplication1.My.Resources.Resources.pelota_5
            End With

            Pausa(LAPSO)

            With PictureBox1
                .Image = WindowsApplication1.My.Resources.Resources.pelota_6
            End With

            Pausa(LAPSO)

            With PictureBox1
                .Image = WindowsApplication1.My.Resources.Resources.pelota_7
            End With

            Pausa(LAPSO)

            With PictureBox1
                .Image = WindowsApplication1.My.Resources.Resources.pelota_8
            End With

            Pausa(LAPSO)

        Loop
    End Sub


    Private Sub Pausa(ByVal segundos As Double)
        'Generación de pausa
        Dim esperaTmp As Long = My.Computer.Clock.TickCount + (segundos * 1000)

        While esperaTmp > My.Computer.Clock.TickCount

            System.Windows.Forms.Application.DoEvents()

        End While

    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e _
                           As System.EventArgs) Handles MyBase.Load
        Button1.Text = "Aumentar Velocidad"
        Button2.Text = "Disminuir velocidad"
        Button3.Text = "Iniciar"
        Button4.Text = "Finalizar"

    End Sub


    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e _
                              As System.EventArgs) Handles Button4.Click
        Me.Close()
    End Sub
End Class

Sintaxis alternativa

Public Class Form1
    Dim LAPSO As Double = 0.1
    Dim num_imagen As Integer
    Dim nom_archivo As String

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As  _
                              System.EventArgs) Handles Button1.Click
        'Decremento de del tiempo de giro
        Label1.Text = "A toda máquina"

        If LAPSO - 0.01 < 0.01 Then
            Label1.Text = "No puedo más"
        Else
            LAPSO = LAPSO - 0.01
        End If

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e _
                              As System.EventArgs) Handles Button2.Click
        Label1.Text = "Descansando"
        'Incremento del tiempo de giro
        If LAPSO + 0.01 = 0.1 Then
            Label1.Text = "Muy lento"
        Else
            LAPSO = LAPSO + 0.01
        End If

    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e _
                              As System.EventArgs) Handles Button3.Click

        Label1.Text = "Suavecito"
        'Repetición perenne
        Do While True

            num_imagen = 1

            Do While num_imagen <= 8
                nom_archivo = "c:\pruebas\pelota_" + LTrim(Str(num_imagen)) + ".jpg"
                ' PictureBox1.ImageLocation = nom_archivo 'SINTAXIS ALTERNATIVA
                ' CallByName(PictureBox1, "ImageLocation", vbLet, nom_archivo) 'OTRA ALTERNATIVA
                PictureBox1.Image = Image.FromFile(nom_archivo)
                num_imagen = num_imagen + 1
                Pausa(LAPSO)

            Loop

        Loop

    End Sub


    Private Sub Pausa(ByVal segundos As Double)
        'Generación de pausa
        Dim esperaTmp As Long = My.Computer.Clock.TickCount + (segundos * 1000)

        While esperaTmp > My.Computer.Clock.TickCount

            System.Windows.Forms.Application.DoEvents()

        End While

    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e _
                           As System.EventArgs) Handles MyBase.Load
        Button1.Text = "Aumentar Velocidad"
        Button2.Text = "Disminuir velocidad"
        Button3.Text = "Iniciar"
        Button4.Text = "Finalizar"

    End Sub


    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e _
                              As System.EventArgs) Handles Button4.Click
        Me.Close()
    End Sub
End Class


Ejercicio Nº  19 (Efecto imán)

Generar una aplicación que encaje el formulario en la esquina inferior derecha del monitor, cuando lo desplace  "cerca" de ésta.

Código:

Public Class Form1
    Dim dvsi As Single
    Dim dvsd As Single
    Dim dvid As Single
    Dim dvii As Single
    Dim minimo As Single
    Dim radio As Single

    Private Sub Form1_Move(ByVal sender As System.Object, ByVal e _
                           As System.EventArgs) Handles MyBase.Move

        'Vértice superior izquierdo del computador
        Dim vsi_c As New Point(0, 0)
        'Vértice superior izquierdo del formulario
        Dim vsi_f As New Point(Me.Left, Me.Top)

        'Vértice superior derecho del computador
        Dim vsd_c As New Point(My.Computer.Screen.WorkingArea.Width, 0)

        'Vértice superior derecho del formulario
        Dim vsd_f As New Point(Me.Left + Me.Width, Me.Top)

        Dim vid_c As New Point(My.Computer.Screen.WorkingArea.Width, _
                               My.Computer.Screen.WorkingArea.Height)
        Dim vid_f As New Point(Me.Left + Me.Width, Me.Top + Me.Height)

        Dim vii_c As New Point(0, My.Computer.Screen.WorkingArea.Height)
        Dim vii_f As New Point(Me.Left, Me.Top + Me.Height)

        'distancia del vértice SI_C al SI_F
        dvsi = Math.Sqrt(vsi_f.X ^ 2 + vsi_f.Y ^ 2)

        'distancia del vértice SD_C al SD_F
        dvsd = Math.Sqrt((vsd_c.X - vsd_f.X) ^ 2 + (vsd_c.Y - vsd_f.Y) ^ 2)
        dvid = Math.Sqrt((vid_c.X - vid_f.X) ^ 2 + (vid_c.Y - vid_f.Y) ^ 2)
        dvii = Math.Sqrt(vii_f.X ^ 2 + (vii_c.Y - vii_f.Y) ^ 2)

        minimo = dvsi

        If dvsd <= minimo Then
            minimo = dvsd
        End If

        If dvid <= minimo Then
            minimo = dvid
        End If

        If dvii <= minimo Then
            minimo = dvii
        End If

        radio = minimo ' define cuan cerca se dispara el imán. Probar con 40

        If dvid = minimo And minimo <= radio And Not (My.Computer.Keyboard.CtrlKeyDown) Then
            ' Desplazar el formulario con CTRL pulsado para no activar el "imán"
            Me.Location = New Point(My.Computer.Screen.WorkingArea.Width - Me.Width, _
                                    My.Computer.Screen.WorkingArea.Height - Me.Height)

        End If

    End Sub
End Class


Ejercicio Nº  20 (Presentador de láminas tipo PowerPoint)

    Desarrollar una aplicación para mostrar láminas secuencialmente como si se tratare de PowerPoint.




Public Class Form1
    Dim nom_archivo As String = "c:\fotos_camara\fotos_catamayo\dcim\101canon\img_2011.jpg"
    Dim pos_x As Integer
    Dim pos_y As Integer
    Dim dat_lam As Integer
    Dim dat_det As String
    Dim dat_fil As Integer = 0
    Dim dat_col As Integer
    Dim dat_cel As Integer
    Dim bandera As Integer = 1
    Dim contador As String = 5

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) _
        Handles MyBase.Load

        ' Me.WindowState() = 2 'inicio maximizado
        Me.WindowState() = FormWindowState.Maximized 'inicio maximizado

        Me.BackgroundImage = Image.FromFile(nom_archivo)
        Me.BackgroundImageLayout = ImageLayout.Stretch

        ' ShowInTaskbar = false 'para no mostrar el icono en ejecución en la barra de tareas

        Label1.Text = "Láminas a presentar: "
        pos_x = Me.ClientSize.Width - TextBox2.Width - Label1.Width - 10
        pos_y = Me.ClientSize.Height

        TextBox2.TabIndex = 0 'para que el cursor se coloque en este box al iniciar aplicación
        DataGridView1.TabIndex = 1 'El cursor se coloca en el listbox después del textbox

        DataGridView1.Location = New Point(Me.ClientSize.Width - DataGridView1.Width, pos_y - _
                                           DataGridView1.Height)

        Label1.Location = New Point(pos_x, 5)
        TextBox2.Location = New Point(Me.ClientSize.Width - TextBox2.Width, 5)

        Button1.Location = New Point(Me.ClientSize.Width - TextBox2.Width, 30)
        Button1.Text = "Iniciar"

        DataGridView1.AllowUserToAddRows = False
        DataGridView1.Columns(0).Width = 4
        DataGridView1.SelectionMode = 1 'selección full row
        DataGridView1.ReadOnly = True

        For Each col As DataGridViewColumn In DataGridView1.Columns
            col.SortMode = DataGridViewColumnSortMode.NotSortable
        Next

        'ALTERNATIVA PARA NO ORDENAR COLUMNAS EN EJECUCION

        'DataGridView1.Columns("lamina").SortMode = DataGridViewColumnSortMode.NotSortable

        'With DataGridView1
        '    .Columns("detalle").SortMode = DataGridViewColumnSortMode.NotSortable
        'End With

        DataGridView1.Hide()

    End Sub

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

        If Val(TextBox2.Text) > 0 Then 'Con este valor puede desarrollar un LOOP si requiere
            TextBox2.Hide()

            DataGridView1.Show()

            dat_lam = 100
            dat_det = "Buen día"
            DataGridView1.Rows.Add(New String() {dat_lam, dat_det})

            dat_lam = 101
            dat_det = "Presentación"
            DataGridView1.Rows.Add(New String() {dat_lam, dat_det})

            dat_lam = 102
            dat_det = "Agenda"

            DataGridView1.Rows.Add(New String() {dat_lam, dat_det})

            dat_lam = 103
            dat_det = "Primera Forma Normal"
            DataGridView1.Rows.Add(New String() {dat_lam, dat_det})

            dat_lam = 104
            dat_det = "Segunda Forma Normal"
            DataGridView1.Rows.Add(New String() {dat_lam, dat_det})

            dat_lam = 105
            dat_det = "Tercera Forma Normal"
            DataGridView1.Rows.Add(New String() {dat_lam, dat_det})

            DataGridView1.ReadOnly = True

            Button1.Hide()
            Label1.Hide()

            dat_cel = 1924 + Me.DataGridView1.Item(0, 0).Value 'el 1924 es por caso particular
            nom_archivo = "c:\fotos_camara\fotos_catamayo\dcim\101canon\img_" + _
                LTrim(Str(dat_cel)) + ".jpg"
            Me.BackgroundImage = Image.FromFile(nom_archivo) 'POR EJEMPLO IMG_2024.JPG
            Me.BackgroundImageLayout = ImageLayout.Stretch

        End If
    End Sub

    Private Sub DataGridView1_CellClick(ByVal sender As System.Object, ByVal e As  _
                        System.Windows.Forms.DataGridViewCellEventArgs) _
                    Handles DataGridView1.CellClick

        bandera = 0
        dat_fil = Me.DataGridView1.CurrentRow.Index
        dat_cel = 1924 + Me.DataGridView1.Item(0, dat_fil).Value 'guardar el valor CELDA

        nom_archivo = "c:\fotos_camara\fotos_catamayo\dcim\101canon\img_" + _
            LTrim(Str(dat_cel)) + ".jpg"
        Me.BackgroundImage = Image.FromFile(nom_archivo) 'POR EJEMPLO IMG_1925.JPG
        Me.BackgroundImageLayout = ImageLayout.Stretch
        bandera = 1

    End Sub


    Protected Overrides Function ProcessCmdKey(ByRef msg As  _
                                               System.Windows.Forms.Message, _
                                               ByVal keyData As  _
                                               System.Windows.Forms.Keys) As Boolean

        ' If (Not DataGridView1.Focused) Then   Return MyBase.ProcessCmdKey(msg, keyData)

        If (keyData = Keys.Down) Then

            'Recuerde que las filas se cuentan de 0 a n
            If dat_fil < DataGridView1.RowCount - 1 Then
                dat_fil = dat_fil + 1
            End If

            dat_cel = 1924 + Me.DataGridView1.Item(0, dat_fil).Value

            nom_archivo = "c:\fotos_camara\fotos_catamayo\dcim\101canon\img_" + _
                LTrim(Str(dat_cel)) + ".jpg"
            Me.BackgroundImage = Image.FromFile(nom_archivo)
            Me.BackgroundImageLayout = ImageLayout.Stretch

            'RETURN TRUE
        End If

        If (keyData = Keys.Up) Then

            If dat_fil > 0 Then
                dat_fil = dat_fil - 1
            End If

            dat_cel = 1924 + Me.DataGridView1.Item(0, dat_fil).Value

            nom_archivo = "c:\fotos_camara\fotos_catamayo\dcim\101canon\img_" + _
                LTrim(Str(dat_cel)) + ".jpg"
            Me.BackgroundImage = Image.FromFile(nom_archivo)
            Me.BackgroundImageLayout = ImageLayout.Stretch

            ' Return True
        End If
        ' Return True

        Return MyBase.ProcessCmdKey(msg, keyData)

    End Function

End Class


Ejercicio Nº  21 (Pequeño sistema de control de estudios)

    Desarrollar una aplicación para llevar el control de notas por materia de alumnos. La idea es trabajar con la base de datos SQL Base_tutorial_01 creada en el tutorial SQL con las tablas siguientes:

Tabla_primer_nombre
Cédula
Primer_nombre

Tabla_segundo_nombre
Cédula
Segundo_nombre

Tabla_primer_apellido (Esta tabla será tomada como la matriz, principal o pivote)
Cédula
Primer_apellido

Tabla_materias
Código_materia
Nombre_materia

Tabla_Nota_materia
Cédula
Código_materia
Nota

Pasos:

1. Copiar la base de datos base_tutorial_01 en el directorio donde puso la base de datos
    del ejercio 15 para efectos de evitar un error de recurso.
 
2. Crear el formulario (versión beta) utilizando:

 

     3  GroupBox
     6  Labels
     7  Botones
     4  MaskedTextBox
     1  Tabla_primer_apellidoDataGridView

 


3.  Poner para la base de datos base_tutorial_01
     la misma propiedad asignada a la base  NORTHWND.MDF del ejercicio  15



3. Ingresar el código

Public Class Form1
    Dim AGREGAR_ced As Boolean = True 'bandera de cedula
    Dim agregar_primn As Boolean = False 'bandera de primer nombre
    Dim agregar_prima As Boolean = False 'bandera de primer apellido

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) _
        Handles MyBase.Load
        'TODO: esta línea de código carga datos en la tabla
        'Base_tutorial_01DataSet.tabla_primer_apellido' Puede moverla o
        'quitarla según sea necesario.
        Me.Tabla_primer_apellidoTableAdapter.Fill(Me.Base_tutorial_01DataSet.tabla_primer_apellido)

        Tabla_primer_apellidoDataGridView.Hide() ' que no aparezca en el formulario

        Label1.Text = "Cédula"
        Label2.Text = "Primer Nombre"
        Label3.Text = "Segundo Nombre"
        Label4.Text = "Primer Apellido"
        Label5.Text = ""
        Label6.Text = ""

        Label5.ForeColor = Color.Red

        MaskedTextBox1.Mask = "9999999999"

        Button4.TabIndex = 0 'orden del foco
        MaskedTextBox1.TabIndex = 1 'orden del foco
        MaskedTextBox2.TabIndex = 2
        MaskedTextBox3.TabIndex = 3
        MaskedTextBox4.TabIndex = 4

        GroupBox1.Text = "Datos del alumno"
        GroupBox1.BackColor = Color.Bisque

        Button1.Text = "Ingresar Data"
        Button2.Text = "Nuevo"
        Button3.Text = "Cancelar"
        Button4.Text = "Nuevo alumno"
        Button4.Focus()

        Button7.BackColor = Color.Red
        Button7.Text = "Salir"
    End Sub

    Private Sub maskedTextBox1_KeyPress(ByVal sender As Object, ByVal e As  _
                                        System.Windows.Forms.KeyPressEventArgs) _
                                    Handles MaskedTextBox1.KeyPress
        'Ingreso de la cédula (primeros 2 dígitos entre 01-22 y longitud=10)

        Label6.Text = ""

        If InStr(1, MaskedTextBox1.Text & e.KeyChar, e.KeyChar) = 1 Then
            If Val(e.KeyChar) >= 3 Then
                e.KeyChar = ""
                Label5.Text = "Primeros dos dígitos 01 a 22"
            Else
                Label5.Text = "Tipear 10 dígitos"
            End If
        End If

        If Len(MaskedTextBox1.Text & e.KeyChar) = 2 Then
            If Val(MaskedTextBox1.Text + e.KeyChar) > 22 Then
                Beep()
                e.KeyChar = ""
                Label5.Text = "Primeros dos dígitos 01 a 22"
            Else
                Label5.Text = "Tipear 10 dígitos"
            End If
        End If

        If Len(MaskedTextBox1.Text & e.KeyChar) >= 3 Then

            Label5.Text = "Tipear 10 dígitos"

        End If

    End Sub

    Private Sub maskedTextBox2_KeyPress(ByVal sender As Object, ByVal e As  _
                                        System.Windows.Forms.KeyPressEventArgs) _
                                    Handles MaskedTextBox2.KeyPress
        Label6.Text = ""
        Label5.Text = "Máximo 15 caracteres"
    End Sub

    Private Sub maskedTextBox3_KeyPress(ByVal sender As Object, ByVal e As  _
                                        System.Windows.Forms.KeyPressEventArgs) _
                                    Handles MaskedTextBox3.KeyPress
        Label6.Text = ""
        Label5.Text = "Máximo 15 caracteres"

    End Sub

    Private Sub maskedTextBox4_KeyPress(ByVal sender As Object, ByVal e As  _
                                        System.Windows.Forms.KeyPressEventArgs) _
                                    Handles MaskedTextBox4.KeyPress
        Label6.Text = ""
        Label5.Text = "Máximo 15 caracteres"
    End Sub

    Private Sub MaskedTextBox1_Leave(ByVal sender As System.Object, ByVal e As  _
                                     System.EventArgs) Handles MaskedTextBox1.Leave
        ' Validación de la cédula (dos primeros dígitos entre 01-22 y longitud 10)
        Dim n_fila As Integer = 0
        Label5.Text = ""

        If Len(MaskedTextBox1.Text) < 10 Then
            If Len(MaskedTextBox1.Text) > 0 Then
                Label5.Text = "Completar datos de cédula "
                MaskedTextBox1.Focus()

            Else
                Label5.Text = "Data inválida"
                Button4.Focus()

            End If

        Else
            'buscar si existe en la base de datos

            n_fila = 0
            Do While n_fila <= Tabla_primer_apellidoDataGridView.RowCount

                If Tabla_primer_apellidoDataGridView.Item(0, n_fila).Value = "" Then
                    Exit Do
                End If

                If Tabla_primer_apellidoDataGridView.Item(0, n_fila).Value = _
                    Val(MaskedTextBox1.Text) Then
                    Label5.Text = "Dato existente en la tabla"

                    MaskedTextBox1.Focus()
                    AGREGAR_ced = False
                    Exit Do
                Else
                    n_fila = n_fila + 1
                    AGREGAR_ced = True 'por si fue puesto a false por existir en la base
                    Label5.Text = "Máximo 15 caracteres"
                End If

            Loop

        End If

    End Sub

    Private Sub MaskedTextBox2_Leave(ByVal sender As System.Object, ByVal e As  _
                                     System.EventArgs) Handles MaskedTextBox2.Leave

        If Len(MaskedTextBox2.Text) = 0 Then
            Label5.Text = "Data inválida"
            Button4.Focus()
        Else
            agregar_primn = True
        End If

    End Sub
    Private Sub MaskedTextBox4_Leave(ByVal sender As System.Object, ByVal e As  _
                                     System.EventArgs) Handles MaskedTextBox4.Leave
        ' validación ingreso apellido
        If Len(MaskedTextBox4.Text) = 0 Then
            Label5.Text = "Data inválida"
            Button4.Focus()
        Else
            agregar_prima = True
        End If

    End Sub

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) _
        Handles Button1.Click
        ' íngresar data validada
        If (AGREGAR_ced And Len(MaskedTextBox1.Text) = 10) And agregar_prima _
            And agregar_primn Then
            Base_tutorial_01DataSet.tabla_primer_apellido.Addtabla_primer_apellidoRow(Val(MaskedTextBox1.Text), MaskedTextBox2.Text)
            'Me.Validate()
            'Me.Tabla_primer_apellidoBindingSource.EndEdit()
            Me.TableAdapterManager.UpdateAll(Me.Base_tutorial_01DataSet)

            MaskedTextBox1.Text = ""
            MaskedTextBox2.Text = ""
            MaskedTextBox3.Text = ""
            MaskedTextBox4.Text = ""

            Label5.Text = "Tipear 10 dígitos"
            Label6.Text = "Data ingresada"

            MaskedTextBox1.Focus()

        Else
            Label6.Text = "Data no ingresada"
        End If

    End Sub
    Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) _
        Handles Button2.Click
        'Ingreso de nuevo alumno
        Label5.Text = "Tipear 10 dígitos"
        Label6.Text = ""

        MaskedTextBox1.Text = ""
        MaskedTextBox2.Text = ""
        MaskedTextBox3.Text = ""
        MaskedTextBox4.Text = ""

        MaskedTextBox1.Focus()
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
        Handles Button3.Click
        'módulo cancelar ingreso alumno
        Label5.Text = "Tipear 10 dígitos"
        Label6.Text = ""

        MaskedTextBox1.Text = ""
        MaskedTextBox2.Text = ""
        MaskedTextBox3.Text = ""
        MaskedTextBox4.Text = ""

        MaskedTextBox1.Focus()
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
        Handles Button4.Click
        'Para entrar al módulo de alumnos
        Label5.Text = "Tipear 10 dígitos"
        Label6.Text = ""

        MaskedTextBox1.Text = ""
        MaskedTextBox2.Text = ""
        MaskedTextBox3.Text = ""
        MaskedTextBox4.Text = ""

        MaskedTextBox1.Focus()

    End Sub

    Private Sub Button7_Click(sender As System.Object, e As System.EventArgs) _
        Handles Button7.Click
        'PARA SALIR DEL SISTEMA

        'End
        Application.Exit() 'cierra ventanas y todo
        ' Me.Close() 'cierra el formulario actual
    End Sub
End Class


Ejercicio Nº  22

    Desarrollar una aplicación para enviar e_mails.



En fin, no sé cual es la experiencia que han tenido, no olviden comentarla que no solo de pan vive el hombre.

Buen camino

3 comentarios:

  1. Gracias Padrino por la enseñanza de los círculos, la marioneta y por toda su sabia ilustración.
    Mateo Córdova
    Posdata: me sirvió sin errores

    ResponderEliminar
  2. mil gracias, estoy retomando mi camino gracias a usted

    ResponderEliminar

Escribir comentario, el más fácil es como anónimo