almacenar estructura en cadena en .NET

(1/1)

andaluz:
Hola a todos, tengo que almacenar en una cadena una estructura (nombre, apellidos, direccion, ciudad, telefono, fecha_nacimiento) esto lo tengo que hacer en un formulario, yo he realizado el formulario y el siguiente codigo:

Código
Public Class frm_Alumno
 
   Public Structure str_Alumnos
       Public nombre As String
       Public apellidos As String
       Public direccion As String
       Public telefono As String
       Public fecha_nac As Date
   End Structure
 
   Dim nregistros As UShort
   Public S_Alumnos() As str_Alumnos
 
   Private Sub cmb_Borrar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmb_Borrar.Click
       txt_Nombre.Text = ""
       txt_Apellido.Text = ""
       txt_Direccion.Text = ""
       txt_Telefono.Text = ""
       txt_Fecha_Nacimiento.Text = ""
   End Sub
 
   Private Sub cmb_Insertar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmb_Insertar.Click
 
 
       'pnl_Alumno.Visible = True
 
       '        aqui le tendria que realizar un bucle, para que recorra los campos de la estructura tantas veces
       ' como yo quiera, pero nuse de que manera lo tendrķa que realizar, me pueden ayudar??
       S_Alumnos(CInt(lbl_Contador.Text)).nombre = txt_Nombre.Text
       S_Alumnos(CInt(lbl_Contador.Text)).apellidos = txt_Apellido.Text
       S_Alumnos(CInt(lbl_Contador.Text)).direccion = txt_Direccion.Text
       S_Alumnos(CInt(lbl_Contador.Text)).telefono = txt_Telefono.Text
       S_Alumnos(CInt(lbl_Contador.Text)).fecha_nac = CDate(txt_Fecha_Nacimiento.Text)
       lbl_Contador.Text = CInt(lbl_Contador.Text) + 1
   End Sub
 
   Private Sub cmb_Buscar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmb_Buscar.Click
       Dim i As Integer
       Dim buscar_nombre, buscar_apellido As String
 
       buscar_nombre = InputBox("Introduce el nombre a buscar: ")
       buscar_apellido = ("Introduce el apellido a buscar: ")
 
       For i = 0 To nregistros
           If S_Alumnos(i).nombre = txt_Nombre.Text = S_Alumnos(i).apellidos = txt_Apellido.Text Then
               MsgBox("Nombre: " & txt_Nombre.Text & vbCrLf &
                      "Apellido: " & txt_Apellido.Text & vbCrLf &
                      "Direccion: " & txt_Direccion.Text & vbCrLf &
                      "Telefono: " & txt_Telefono.Text & vbCrLf &
                      "Fecha de Nacimiento: " & txt_Fecha_Nacimiento.Text)
           End If
       Next i
   End Sub
 
   Private Sub frm_Alumno_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
       Dim nregistros As UShort
       nregistros = CUShort(InputBox("Introduce el numero de registros"))
       lbl_Total.Text = nregistros
       'pnl_Alumno.Visible = False
   End Sub
End Class
 

en el codigo les he dejado un comentario en la parte que creo yo que deberia de ir el bucle.

espero que me puedan ayudar, saludos

Navegación

[0] Índice de Mensajes