0% found this document useful (0 votes)
50 views7 pages

Practica 5

The document describes code for a login form and calculator application in Visual Basic.NET. The login form allows users to log in with different credentials that determine the available operations in the calculator. The calculator form performs basic math operations like addition, subtraction, multiplication and division based on the logged in user and selected operation. It validates the user input and displays the result. Closing the calculator returns to the login screen.

Uploaded by

api-335606883
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views7 pages

Practica 5

The document describes code for a login form and calculator application in Visual Basic.NET. The login form allows users to log in with different credentials that determine the available operations in the calculator. The calculator form performs basic math operations like addition, subtraction, multiplication and division based on the logged in user and selected operation. It validates the user input and displays the result. Closing the calculator returns to the login screen.

Uploaded by

api-335606883
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

ERICK ANTONIO FLORES SMIS037916 GRUPO A

EJERCICIO 1:
CAPTURAS:

ERICK ANTONIO FLORES SMIS037916 GRUPO A

CDIGO:
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles [Link]
[Link]()
Agregar()
End Sub
'Agregar elementos al combo box
Public Sub Agregar()
With [Link]
.Add("Sumar")
.Add("Restar")
.Add("Multiplicar")
.Add("Dividir")
End With
End Sub
'Validar
Public Function Validar() As Boolean
If [Link] = "" Or [Link] = "" Then
MsgBox("An no ha rellenado los campos", [Link])
Return False
ElseIf Not IsNumeric([Link]) Or Not IsNumeric([Link]) Then
MsgBox("Slo se aceptan nmeros", [Link])

ERICK ANTONIO FLORES SMIS037916 GRUPO A


Return False
Else
Return True
End If
End Function
'Operaciones
Public Function Suma(ByVal num1 As Decimal, ByVal num2 As Decimal)
Return num1 + num2
End Function
Public Function Resta(ByVal num1 As Decimal, ByVal num2 As Decimal)
Return num1 - num2
End Function
Public Function Multiplicacion()
Return [Link] * [Link]
End Function
Public Function Division(num1 As Decimal, num2 As Decimal)
Return [Link] / [Link]
End Function
'Evento cambiar index o seleccin
Public Sub operacion_SelectedIndexChanged(sender As Object, e As EventArgs)
Handles [Link]
If Validar() = True Then
Select Case [Link]
Case 0
[Link] = Suma([Link], [Link])
Case 1
[Link] = Resta([Link], [Link])
Case 2
[Link] = Multiplicacion()
Case 3
[Link] = Division([Link], [Link])
End Select
Else
[Link]()
[Link]()
[Link]()
[Link] = ""
End If
End Sub
End Class

ERICK ANTONIO FLORES SMIS037916 GRUPO A

EJERCICIO 2:
CAPTURAS:

CDIGO:

-PRIMER FORMULARIO:
Public Class login
Public t As String
Private Sub login_Load(sender As Object, e As EventArgs) Handles [Link]
[Link]()
End Sub

ERICK ANTONIO FLORES SMIS037916 GRUPO A


'Llamar al otro formulario
Public Sub llamar()
Dim form1 As New Form1
[Link] = t
[Link]()
[Link]()
End Sub
'Validar al usuario
Public Sub entrar_Click(sender As Object, e As EventArgs) Handles [Link]
If [Link] = "ugb" And [Link] = "123456" Then
t = "Usuario: ugb"
llamar()
ElseIf [Link] = "ugbSM" And [Link] = "654321" Then
t = "Usuario: ugbSM"
llamar()
Else
MsgBox("Usuario o contrsea incorrecta", [Link])
[Link]()
[Link]()
End If
End Sub
'Entrar como invitado
Private Sub invitado_Click(sender As Object, e As EventArgs) Handles [Link]
t = "Usuario: invitado"
llamar()
End Sub
End Class

-SEGUNDO FORMULARIO:
Public Class Form1
Dim a As New login()
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles [Link]
[Link]()
Agregar()
End Sub
'Agregar elementos al combo box...
Public Sub Agregar()
Dim i As Integer = Len(a.t)
If [Link] = "Usuario: ugb" Then
With [Link]
.Add("Sumar")
.Add("Restar")
.Add("Multiplicar")
.Add("Dividir")
End With
ElseIf [Link] = "Usuario: ugbSM" Then
With [Link]
.Add("Restar")
.Add("Multiplicar")
.Add("Dividir")

ERICK ANTONIO FLORES SMIS037916 GRUPO A


End With
Else
With [Link]
.Add("Sumar")
End With
End If
End Sub
'Validar
Public Function Validar() As Boolean
If [Link] = "" Or [Link] = "" Then
MsgBox("An no ha rellenado los campos", [Link])
Return False
ElseIf Not IsNumeric([Link]) Or Not IsNumeric([Link]) Then
MsgBox("Slo se aceptan nmeros", [Link])
Return False
Else
Return True
End If
End Function
'Operaciones
Public Function Suma(ByVal num1 As Decimal, ByVal num2 As Decimal)
Return num1 + num2
End Function
Public Function Resta(ByVal num1 As Decimal, ByVal num2 As Decimal)
Return num1 - num2
End Function
Public Function Multiplicacion()
Return [Link] * [Link]
End Function
Public Function Division(num1 As Decimal, num2 As Decimal)
Return [Link] / [Link]
End Function
'Evento cambiar index o seleccin
Private Sub operacion_SelectedIndexChanged(sender As Object, e As EventArgs) Handles
[Link]
If Validar() = True Then
Select Case [Link]
Case "Sumar"
[Link] = Suma([Link], [Link])
Case "Restar"
[Link] = Resta([Link], [Link])
Case "Multiplicar"
[Link] = Multiplicacion()
Case "Dividir"
[Link] = Division([Link], [Link])
End Select
Else
[Link]()
[Link]()
[Link]()
[Link] = ""
End If
End Sub

ERICK ANTONIO FLORES SMIS037916 GRUPO A


'Abre el Login cuando se presiona salir
Private Sub Form1_FormClosed(sender As Object, e As FormClosedEventArgs) Handles
[Link]
[Link]()
[Link]()
[Link]()
End Sub
End Class

You might also like