HOLA A TODOS, COMO PUEDO HACER PARA K ME BUSQUE UN CODIGO INGRESADO EN MI PROGRAMA Y AL MOMENTO DE BUSCAR ME INDIQUE SI EXISTE O NO EXISTE. DE ANTEMANO GRACIAS - ESTOY TRBAJANOD EN APLICACION PARA WINDOWS
Public Class Form1
Public Shared i As Integer = 0
Dim alum(5) As ListaAlumno.ListaAlumno
Sub agregar()
i += 1
alum(i).codAlum = mtxtCodigo.Text
alum(i).Nombre = txtNombre.Text
alum(i).Apellido = txtApellidos.Text
alum(i).Especialidad = cbEspecialidad.Text
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub btnAñadir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAñadir.Click
agregar()
listAlumno.Items.Add(alum(i).codAlum & " " & alum(i).Nombre & " " & alum(i).Apellido & " " & alum(i).Especialidad)
MsgBox("Alumno guardado!", MsgBoxStyle.OkOnly, "OK")
End Sub
Private Sub btnNuevo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNuevo.Click
If i < 5 Then
mtxtCodigo.Text = ""
txtNombre.Text = ""
txtApellidos.Text = ""
cbEspecialidad.Text = ""
Else
MsgBox("Lista llena!", MsgBoxStyle.OkOnly, "OK")
End If
End Sub
Private Sub btnBuscar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBuscar.Click
For i = 0 To 5
If mtxtCodigo.Text = alum(i).codAlum Then
MsgBox("el codigo existe " & txtBuscar.Text)
Exit For
Else
MsgBox("el codigo no existe " & txtBuscar.Text)
Exit For
End If
Next
End Sub
End Class
ESTO ES MI CLASE:
Public Class ListaAlumno
Public Structure ListaAlumno
Public codAlum As Integer
Public Nombre As String
Public Apellido As String
Public Especialidad As String
End Structure
End Class
Public Class Form1
Public Shared i As Integer = 0
Dim alum(5) As ListaAlumno.ListaAlumno
Sub agregar()
i += 1
alum(i).codAlum = mtxtCodigo.Text
alum(i).Nombre = txtNombre.Text
alum(i).Apellido = txtApellidos.Text
alum(i).Especialidad = cbEspecialidad.Text
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub btnAñadir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAñadir.Click
agregar()
listAlumno.Items.Add(alum(i).codAlum & " " & alum(i).Nombre & " " & alum(i).Apellido & " " & alum(i).Especialidad)
MsgBox("Alumno guardado!", MsgBoxStyle.OkOnly, "OK")
End Sub
Private Sub btnNuevo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNuevo.Click
If i < 5 Then
mtxtCodigo.Text = ""
txtNombre.Text = ""
txtApellidos.Text = ""
cbEspecialidad.Text = ""
Else
MsgBox("Lista llena!", MsgBoxStyle.OkOnly, "OK")
End If
End Sub
Private Sub btnBuscar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBuscar.Click
For i = 0 To 5
If mtxtCodigo.Text = alum(i).codAlum Then
MsgBox("el codigo existe " & txtBuscar.Text)
Exit For
Else
MsgBox("el codigo no existe " & txtBuscar.Text)
Exit For
End If
Next
End Sub
End Class
ESTO ES MI CLASE:
Public Class ListaAlumno
Public Structure ListaAlumno
Public codAlum As Integer
Public Nombre As String
Public Apellido As String
Public Especialidad As String
End Structure
End Class