You are on page 1of 7

principal

Public Class Form1


Inherits System.Windows.Forms.Form

#Region " Código generado por el Diseñador de Windows Forms "

Public Sub New()


MyBase.New()

'El Diseñador de Windows Forms requiere esta llamada.


InitializeComponent()

'Agregar cualquier inicialización después de la llamada a


InitializeComponent()

End Sub

'Form reemplaza a Dispose para limpiar la lista de componentes.


Protected Overloads Overrides Sub Dispose(ByVal disposing As
Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'Requerido por el Diseñador de Windows Forms


Private components As System.ComponentModel.IContainer

'NOTA: el Diseñador de Windows Forms requiere el siguiente


procedimiento
'Puede modificarse utilizando el Diseñador de Windows Forms.
'No lo modifique con el editor de código.
Friend WithEvents CMDNOTAS As System.Windows.Forms.Button
Friend WithEvents CMDFACTORIAL As System.Windows.Forms.Button
Friend WithEvents CMDPRIMOS As System.Windows.Forms.Button
Friend WithEvents CMDSALIR As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
Me.CMDNOTAS = New System.Windows.Forms.Button
Me.CMDFACTORIAL = New System.Windows.Forms.Button
Me.CMDPRIMOS = New System.Windows.Forms.Button
Me.CMDSALIR = New System.Windows.Forms.Button
Me.SuspendLayout()
'
'CMDNOTAS
'
Me.CMDNOTAS.BackColor =
System.Drawing.Color.FromArgb(CType(224, Byte), CType(224, Byte),
CType(224, Byte))
Me.CMDNOTAS.Location = New System.Drawing.Point(96, 24)
Me.CMDNOTAS.Name = "CMDNOTAS"
Me.CMDNOTAS.Size = New System.Drawing.Size(88, 32)
Me.CMDNOTAS.TabIndex = 0
Me.CMDNOTAS.Text = "NOTAS"
'
'CMDFACTORIAL
'
Me.CMDFACTORIAL.BackColor =
System.Drawing.Color.FromArgb(CType(224, Byte), CType(224, Byte),
CType(224, Byte))
Me.CMDFACTORIAL.Location = New System.Drawing.Point(96, 72)
Me.CMDFACTORIAL.Name = "CMDFACTORIAL"
Me.CMDFACTORIAL.Size = New System.Drawing.Size(88, 32)
Me.CMDFACTORIAL.TabIndex = 1
Me.CMDFACTORIAL.Text = "FACTORIAL"
'
'CMDPRIMOS
'
Me.CMDPRIMOS.BackColor =
System.Drawing.Color.FromArgb(CType(224, Byte), CType(224, Byte),
CType(224, Byte))
Me.CMDPRIMOS.Location = New System.Drawing.Point(96, 120)
Me.CMDPRIMOS.Name = "CMDPRIMOS"
Me.CMDPRIMOS.Size = New System.Drawing.Size(88, 32)
Me.CMDPRIMOS.TabIndex = 2
Me.CMDPRIMOS.Text = "PRIMO"
'
'CMDSALIR
'
Me.CMDSALIR.BackColor =
System.Drawing.Color.FromArgb(CType(224, Byte), CType(224, Byte),
CType(224, Byte))
Me.CMDSALIR.Location = New System.Drawing.Point(176, 192)
Me.CMDSALIR.Name = "CMDSALIR"
Me.CMDSALIR.Size = New System.Drawing.Size(80, 32)
Me.CMDSALIR.TabIndex = 3
Me.CMDSALIR.Text = "SALIR"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.BackColor = System.Drawing.Color.CornflowerBlue
Me.ClientSize = New System.Drawing.Size(288, 253)
Me.Controls.Add(Me.CMDSALIR)
Me.Controls.Add(Me.CMDPRIMOS)
Me.Controls.Add(Me.CMDFACTORIAL)
Me.Controls.Add(Me.CMDNOTAS)
Me.MaximizeBox = False
Me.MinimizeBox = False
Me.Name = "Form1"
Me.Text = "Ejercicio 1 .NET"
Me.ResumeLayout(False)

End Sub

#End Region

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load

End Sub

Private Sub CMDNOTAS_Click(ByVal sender As System.Object, ByVal e


As System.EventArgs) Handles CMDNOTAS.Click
Dim n As New Frmnotas
n.ShowDialog()
End Sub
Private Sub CMDFACTORIAL_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles CMDFACTORIAL.Click
Dim f As New Frmfactorial
f.ShowDialog()
End Sub

Private Sub CMDPRIMOS_Click(ByVal sender As System.Object, ByVal e


As System.EventArgs) Handles CMDPRIMOS.Click
Dim p As New Frmprimo
p.ShowDialog()
End Sub

Private Sub CMDSALIR_Click(ByVal sender As System.Object, ByVal e


As System.EventArgs) Handles CMDSALIR.Click
Close()
End Sub
End Class
Suma
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
limpiar()
End Sub
Sub limpiar()
TXTN1.Clear()
txtn2.Clear()
lbltotal.Text = ""
TXTN1.Focus()
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e


As System.EventArgs) Handles Button2.Click
Dim n1 As Integer, n2 As Integer
Dim suma As Integer
If Not IsNumeric(TXTN1.Text) Then
MsgBox("Ingrese solo Numeros", MsgBoxStyle.Critical)
TXTN1.Focus()
Exit Sub
End If
If Not IsNumeric(txtn2.Text) Then
MsgBox("Ingrese solo Numeros", MsgBoxStyle.Critical)
txtn2.Focus()
Exit Sub
End If
n1 = Val(TXTN1.Text)
n2 = Val(txtn2.Text)
suma = n1 + n2
lbltotal.Text = suma

End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e


As System.EventArgs) Handles Button3.Click
Close()
End Sub

Private Sub TXTN1_TextChanged(ByVal sender As System.Object, ByVal


e As System.EventArgs) Handles TXTN1.TextChanged
End Sub

Private Sub TXTN1_KeyPress(ByVal sender As Object, ByVal e As


System.Windows.Forms.KeyPressEventArgs) Handles TXTN1.KeyPress
If Asc(e.KeyChar) = 13 Then
txtn2.Focus()
End If
End Sub

Private Sub txtn2_TextChanged(ByVal sender As System.Object, ByVal


e As System.EventArgs) Handles txtn2.TextChanged

End Sub

Private Sub txtn2_KeyPress(ByVal sender As Object, ByVal e As


System.Windows.Forms.KeyPressEventArgs) Handles txtn2.KeyPress
If Asc(e.KeyChar) = 13 Then
Button2.Focus()
End If

End Sub

Private Sub Frmsuma_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load

End Sub
End Class

Factorial
Private Sub TextBox1_TextChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles txtnum.TextChanged

End Sub

Private Sub TextBox1_KeyPress(ByVal sender As System.Object, ByVal


e As System.Windows.Forms.KeyPressEventArgs) Handles txtnum.KeyPress
If Asc(e.KeyChar) = 13 Then
cmdver.Focus()

End If
End Sub

Private Sub cmdnuevo_Click(ByVal sender As System.Object, ByVal e


As System.EventArgs) Handles cmdnuevo.Click
txtnum.Clear()
lblre.Text = ""
txtnum.Focus()
End Sub

Private Sub cmdver_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles cmdver.Click

Dim x As Integer, n As Integer, f As Integer


If Not IsNumeric(txtnum.Text) Then
MsgBox("Ingrese solo Numeros", MsgBoxStyle.Critical)
cmdver.Focus()
Exit Sub
End If
If Val(txtnum.Text) < 0 Then
MsgBox("SOLO NUMEROS POSITIVOS")
Exit Sub
End If

n = txtnum.Text
f = 1
For x = 1 To n
f = f * x
Next
lblre.Text = f
End Sub

Private Sub cmdsalir_Click(ByVal sender As System.Object, ByVal e


As System.EventArgs) Handles cmdsalir.Click
Close()
End Sub
End Class

Notas
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles cmdnuevo.Click
txtn1.Clear()
txtn2.Clear()
txtn3.Clear()
lbln1.Text = ""
lbln2.Text = ""
lbln3.Text = ""
lblcriterio.Text = ""
txtn1.Focus()
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e


As System.EventArgs) Handles cmdmostrar.Click
Dim n1 As Integer, n2 As Integer, n3 As Integer, pro As
Integer
If Not IsNumeric(txtn1.Text) Then
MsgBox("Ingrese solo Numeros", MsgBoxStyle.Critical)
txtn2.Focus()
Exit Sub
End If
If Not IsNumeric(txtn2.Text) Then
MsgBox("Ingrese solo Numeros", MsgBoxStyle.Critical)
txtn3.Focus()
Exit Sub
End If
If Not IsNumeric(txtn3.Text) Then
MsgBox("Ingrese solo Numeros", MsgBoxStyle.Critical)
cmdmostrar.Focus()
Exit Sub
End If
n1 = txtn1.Text
lbln1.Text = n1
n2 = txtn2.Text
lbln2.Text = n2
n3 = txtn3.Text
lbln3.Text = n3
pro = (n1 + n2 + n3) / 3

If pro >= 10.5 Then


lblcriterio.Text = "APROBADO"
Else
lblcriterio.Text = "DESAPROBADO"
End If

End Sub

Private Sub cmdsalir_Click(ByVal sender As System.Object, ByVal e


As System.EventArgs) Handles cmdsalir.Click
Close()
End Sub

Private Sub txtn1_TextChanged(ByVal sender As System.Object, ByVal


e As System.EventArgs) Handles txtn1.TextChanged

End Sub

Private Sub txtn1_KeyPress(ByVal sender As Object, ByVal e As


System.Windows.Forms.KeyPressEventArgs) Handles txtn1.KeyPress
If Asc(e.KeyChar) = 13 Then
txtn2.Focus()
If Val(txtn1.Text) > 20 Then
MsgBox("SOLO NUMEROS DE 1 AL 20")
Exit Sub
End If
If Val(txtn1.Text) < 0 Then
MsgBox("SOLO NUMEROS POSITIVOS")
Exit Sub
End If
End If

End Sub

Private Sub txtn2_TextChanged(ByVal sender As System.Object, ByVal


e As System.EventArgs) Handles txtn2.TextChanged

End Sub

Private Sub txtn2_KeyPress(ByVal sender As Object, ByVal e As


System.Windows.Forms.KeyPressEventArgs) Handles txtn2.KeyPress
If Asc(e.KeyChar) = 13 Then
txtn3.Focus()
If Val(txtn2.Text) > 20 Then
MsgBox("SOLO NUMEROS DE 1 AL 20")
Exit Sub
End If
If Val(txtn2.Text) < 0 Then
MsgBox("SOLO NUMEROS POSITIVOS")
Exit Sub
End If
End If

End Sub

Private Sub txtn3_TextChanged(ByVal sender As System.Object, ByVal


e As System.EventArgs) Handles txtn3.TextChanged

End Sub

Private Sub txtn3_KeyPress(ByVal sender As Object, ByVal e As


System.Windows.Forms.KeyPressEventArgs) Handles txtn3.KeyPress
If Asc(e.KeyChar) = 13 Then
cmdmostrar.Focus()
If Val(txtn3.Text) > 20 Then
MsgBox("SOLO NUMEROS DE 1 AL 20")
Exit Sub
End If
If Val(txtn3.Text) < 0 Then
MsgBox("SOLO NUMEROS POSITIVOS")
Exit Sub
End If
End If

End Sub
End Class

Primo
Private Sub cmdnuevo_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles cmdnuevo.Click
txtnum.Clear()
lblre.Text = ""
txtnum.Focus()
End Sub

Private Sub cmdver_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles cmdver.Click
Dim n As Integer, x As Integer, p As Integer
If Not IsNumeric(txtnum.Text) Then
MsgBox("Ingrese solo Numeros", MsgBoxStyle.Critical)
cmdver.Focus()
Exit Sub
End If
n = Val(txtnum.Text)
For x = 1 To n
If n Mod x = 0 Then
p = p + 1
End If
Next
If p = 2 Then
lblre.Text = "PRIMO"
Else
lblre.Text = "NO ES PRIMO"
End If
End Sub

Private Sub cmdsalir_Click(ByVal sender As System.Object, ByVal e


As System.EventArgs) Handles cmdsalir.Click
Close()
End Sub
End Class

You might also like