terça-feira, 30 de novembro de 2010

ficha numero 14 exercicio 2

Private Sub Command1_Click()
Dim x As Integer, y As Integer, mat(1 To 3, 1 To 5) As Integer, cont1 As Integer, cont2 As Integer, cont3 As Integer

Randomize

For x = 1 To 3
For y = 1 To 5
mat(x, y) = Int(Rnd() * 26)
Next y
Next x

For x = 1 To 3
For y = 1 To 5
Picture1.Print mat(x, y);
Next y
Picture1.Print Chr(13)
Next x

cont1 = 0
cont2 = 0
cont3 = 0
For x = 1 To 3
For y = 1 To 5
If mat(x, y) = 0 Then
cont3 = cont3 + 1
Else
If mat(x, y) Mod 2 = 0 Then
cont1 = cont1 + 1
Else
cont2 = cont2 + 1
End If
End If
Next
Next

MsgBox "pares: " & cont1 & " impares: " & cont2 & "  Zeros: " & cont3, vbOKOnly + vbInformation, "Resultado"


End Sub


Private Sub Command2_Click()
If MsgBox("Quer mesmo sair?", vbOKCancel + vbQuestion, "ATENÇÃO") Then
End
End If
End Sub







Sem comentários:

Enviar um comentário