quinta-feira, 16 de dezembro de 2010

ficha de trabalho numero 16 exercicio 3

Private Sub Command1_Click()
Dim x As Integer, cont1 As Integer, cont2 As Integer, cont3 As Integer, cont4 As Integer, cont5 As Integer, cont As Integer
cont1 = 0
cont2 = 0
cont3 = 0
cont4 = 0
cont5 = 0
Do
x = Val(InputBox("Introduza o seu voto (introduza -1 para sair)", "Introdução de votos"))
If x <> -1 Then
cont = cont + 1
If x = 1 Then
cont1 = cont1 + 1

ElseIf x = 2 Then
cont2 = cont2 + 1

ElseIf x = 3 Then
cont3 = cont3 + 1

ElseIf x = 0 Then
cont4 = cont4 + 1

ElseIf x = 4 Then
cont5 = cont5 + 1
End If
End If
Loop Until x = -1
If cont1 > cont2 And cont1 > cont3 Then
Label1.Caption = "1"
ElseIf cont2 > cont1 And cont2 > cont3 Then
Label1.Caption = "2"
ElseIf cont3 > cont1 And cont3 > cont2 Then
Label1.Caption = "3"
End If

Label2.Caption = cont4
Label3.Caption = cont5
Label4.Caption = cont
End Sub



Sem comentários:

Enviar um comentário