Sei sulla pagina 1di 3

CLASE PERSONA

Public Class Persona


Private Id As Integer
Private nombre As String
Private apellido As String
Private correo As String
Sub New(ByVal Id As Integer, ByVal nombre As String, ByVal apellido As
String, ByVal correo As String)
Me.Id = Id
Me.nombre = nombre
Me.apellido = apellido
Me.correo = correo
End Sub
Sub New()
Me.Id = Id
Me.nombre = nombre
Me.apellido = apellido
Me.correo = correo
End Sub
Function GetId() As Integer
Return Me.Id
End Function
Function GetNombre() As String
Return Me.nombre
End Function
Function GetApellido() As String
Return Me.apellido
End Function
Function GetCorreo() As String
Return Me.correo
End Function
Function SetId(ByVal Id As Integer)
Me.Id = Id
Return Nothing
End Function
Function SetNombre(ByVal nombre As String)
Me.nombre = nombre
Return Nothing
End Function
Function SetApellido(ByVal apellido As String)
Me.apellido = apellido
Return Nothing
End Function
Function SetCorreo(ByVal correo As String)
Me.correo = correo
Return Nothing
End Function
End Class
FORMULARIO
Public Class Form1

Private Sub btnGenerar_Click(sender As Object, e As EventArgs) Handles


btnGenerar.Click
Dim per As New Persona(1, "Laura", "Gutierrez", "laura@gmail.com")
Dim id As Integer
Dim nom, apell, corr As String

id = per.GetId
nom = per.GetNombre
apell = per.GetApellido
corr = per.GetCorreo

MessageBox.Show("Los datos almacenados son:" & id & " " & nom & " " &
apell & " " & corr)

End Sub

Private Sub btnCambiar_Click(sender As Object, e As EventArgs) Handles


btnCambiar.Click
Dim per As New Persona
Dim id As Integer
Dim nom, apell, corr As String

per.SetId(CInt(txtcodigo.Text))
per.SetNombre(txtNombre.Text)
per.SetApellido(txtApellido.Text)
per.SetCorreo(txtCorreo.Text)

id = per.GetId
nom = per.GetNombre
apell = per.GetApellido
corr = per.GetCorreo

MessageBox.Show("Los datos almacenados son:" & id & " " & nom & " " &
apell & " " & corr)

End Sub

Private Sub btnIngresar_Click(sender As Object, e As EventArgs) Handles


btnIngresar.Click
Dim per As New Persona
Dim id As Integer
Dim nom, apell, corr As String

per.SetId(8)
per.SetNombre("Tania")
per.SetApellido("Rodriguez")
per.SetCorreo("tania@gmail.com")

id = per.GetId
nom = per.GetNombre
apell = per.GetApellido
corr = per.GetCorreo
MessageBox.Show("Los datos almacenados son:" & id & " " & nom & " " &
apell & " " & corr)

End Sub
End Class

Potrebbero piacerti anche