Você está na página 1de 3

Public Class Exe1 Public nota1, nota2, nota3, media As Double Private Sub btncalc_Click(ByVal sender As System.

Object, ByVal e As System.E ventArgs) Handles btncalc.Click nota1 = 0 nota2 = 0 nota3 = 0 If Not IsNumeric(txtnota1.Text) Or Not IsNumeric(txtnota2.Text) Or Not I sNumeric(txtnota3.Text) Then MsgBox("Verifique os campos existe preencimento incorreto") Else nota1 = CDbl(txtnota1.Text) nota2 = CDbl(txtnota2.Text) nota3 = CDbl(txtnota3.Text) If lstvwcriterio.Items(0).Selected Then If nota1 < nota2 And nota1 < nota3 Then media = (nota2 + nota3) / 2 MsgBox("Menor nota = " & nota1) Else If nota2 < nota1 And nota2 < nota3 Then media = (nota1 + nota3) / 2 MsgBox("Menor nota = " & nota2) Else If nota3 < nota1 And nota3 < nota2 Then media = (nota1 + nota2) / 2 MsgBox("Menor nota = " & nota3) End If End If End If ElseIf lstvwcriterio.Items(1).Selected Then media = (nota1 + nota2 + nota3) / 3 ElseIf lstvwcriterio.Items(2).Selected Then If nota1 < 3 Then MsgBox("Nota menor que 3, favor inserir uma nova nota") txtnota1.Text = "" txtnota1.Focus() ElseIf nota2 < 3 Then MsgBox("Nota menor que 3, favor inserir uma nova nota") txtnota2.Text = "" txtnota2.Focus() ElseIf nota3 < 3 Then MsgBox("Nota menor que 3, favor inserir uma nova nota") txtnota3.Text = "" txtnota3.Focus() Else media = (nota1 + nota2 + nota3) / 3 End If ElseIf lstvwcriterio.Items(3).Selected Then media = (nota3 + nota2) / 2 media = (media + nota1) / 2 End If txtmedia.Text = CStr(media) If media >= 6 Then MsgBox("Aluno Aprovado") Else

MsgBox("Aluno Reprovado") End If End If End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.Even tArgs) Handles MyBase.Load lstvwcriterio.Items(0).Selected = True End Sub End Class

Public Class Exe2 Private Sub btncalc_Click(ByVal sender As System.Object, ByVal e As System.E ventArgs) Handles btncalc.Click Dim fat As Integer fat = 1 Dim numero As Integer If IsNumeric(txtnumero.Text) Then numero = CInt(txtnumero.Text) For x As Integer = 1 To numero fat = fat * x Next txtfatorial.Text = CStr(fat) Else MsgBox("Nmero invlido digite novamente") txtnumero.Text = "" txtnumero.Focus() End If End Sub End Class

Public Class Exe3 Private Sub btncalcular_Click(ByVal sender As System.Object, ByVal e As Syst em.EventArgs) Handles btncalcular.Click Dim num As Double lstresultado.Items.Clear() If IsNumeric(txtnumero.Text) Then num = CDbl(txtnumero.Text) For x As Integer = 0 To num If x Mod 2 = 0 Then lstresultado.Items.Add(x) End If Next Else

MsgBox("Valor invlido difite novamente") txtnumero.Text = "" txtnumero.Focus() End If End Sub End Class

Public Class Exe4 Private Sub btnteste_Click(ByVal sender As System.Object, ByVal e As System. EventArgs) Handles btnteste.Click If txttest.Text = "M" Or txttest.Text = "F" Or txttest.Text = "m" Or txt test.Text = "f" Then If txttest.Text = "m" Or txttest.Text = "M" Then MsgBox("Masculino") Else MsgBox("Feminino") End If Else MsgBox("Digite um valor vlido! Apenas M ou F!") txttest.Text = "" txttest.Focus() End If End Sub End Class

Você também pode gostar