Está en la página 1de 3

Walter Adrián Rabinal de las Llagas

Registro Académico: 201314545


CUI: 2500-21811-0406

2. Realice un programa de calculadora que realice las 4 operaciones básicas y 2 funciones


científicas.

Imports System
Imports Microsoft.VisualBasic
Public Class Form1

Public numero1 As Double


Public numero2 As Double
Public resultado As Double
Private Sub btnsuma_Click(sender As Object, e As EventArgs) Handles btnsuma.Click
numero1 = Val(txtnumero1.Text)
numero2 = Val(txtnumero2.Text)
If Val(txtnumero1.Text) And Val(txtnumero2.Text) Then
resultado = numero1 + numero2
txtresultado.Text = resultado
Else
MsgBox("no ingresó números")
End If
End Sub

Private Sub btnResta_Click(sender As Object, e As EventArgs) Handles btnResta.Click


numero1 = Val(txtnumero1.Text)
numero2 = Val(txtnumero2.Text)
If Val(txtnumero2.Text) And Val(txtnumero2.Text) Then
resultado = numero1 - numero2
txtresultado.Text = resultado
Else
MsgBox("no ingresó números")
End If
End Sub

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


btnMultiplicacion.Click
numero1 = Val(txtnumero1.Text)
numero2 = Val(txtnumero2.Text)
If Val(txtnumero1.Text) And Val(txtnumero2.Text) Then
resultado = numero1 * numero2
txtresultado.Text = resultado
Else
MsgBox("no ingresó números")
End If
End Sub

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


btnDivision.Click
numero1 = Val(txtnumero1.Text)
numero2 = Val(txtnumero2.Text)
If Val(txtnumero1.Text) And Val(txtnumero2.Text) Then
resultado = numero1 / numero2
txtresultado.Text = resultado
Else
MsgBox("la división no es válida")
End If
End Sub

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


btnLimpiar.Click
txtnumero1.Text = ""
txtnumero2.Text = ""
txtresultado.Text = ""
End Sub

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


btnExponencial.Click
numero1 = Val(txtExpLog.Text)

If Val(txtExpLog.Text) Then
resultado = Math.Exp(txtExpLog.Text)
txtresultado.Text = resultado
Else
MsgBox("El exponencial no es válido")
End If

End Sub

Private Sub btnLog_Click(sender As Object, e As EventArgs) Handles btnLog.Click


numero1 = Val(txtExpLog.Text)

If Val(txtExpLog.Text) Then
resultado = Math.Log(txtExpLog.Text)
txtresultado.Text = resultado
Else
MsgBox("El logaritmo no es válido")
End If

End Sub
End Class
4. Cree un programa que permita saber si un número es primo.

Module Module1

Sub Main()
Dim a As Integer = 0
'Dim n As Integer

Console.WriteLine("Ingrese el Número: ")


Dim n = Val(Console.ReadLine)
For i As Integer = 1 To n + 1
If (n Mod i = 0) Then
a = a + 1
End If
Next i
If (a <> 2) Then
Console.WriteLine("No es Primo")
Console.ReadLine()

Else
Console.WriteLine("Si es Primo")
Console.ReadLine()
End If

End Sub
End Module

También podría gustarte