domingo, 6 de dezembro de 2009

Ficha 15-1



Private Sub cmd1_Click()

Dim peso(1 To 5) As Single, i As Integer

soma = 0

For i = 1 To 5
peso(i) = Val(InputBox("Introduza o " & i & "º Peso", "Pesos"))
Picture1.Print peso(i) & "kg"
soma = soma + peso(i)
Next i

media = soma / (i - 1)

Picture1.Print "A soma é de: " & soma & "kg"
Picture1.Print "A média dos pesos é: " & media & "kg"

For i = 1 To 5
If peso(i) > media Then
Picture1.Print i & "º peso acima da média com [" & peso(i) & "]kg"
End If
Next i

End Sub

Ficha 14-1 à 14-9



Private Sub Command1_Click()
Dim n As Integer, num As Integer, i As Integer

num = Val(InputBox("Introduza o número", "Form1"))

If num = 0 Then
num = MsgBox("Introduza um número!", vbOKOnly + vbInformation, "Informação")
ElseIf num > 0 Then
For n = 2 To num - 1
If num Mod n = 0 Then
i = 1
End If
Next n
If i = 1 Then
Picture1.Print Tab(7); num; "nao é primo"
Else
Picture1.Print Tab(8); num; "é primo"
End If
End If

End Sub





Private Sub Command1_Click()

Dim i As Integer, cont1 As Integer, cont2 As Integer, n As Integer

cont1 = 0
cont2 = 0

Picture1.Cls
Picture1.Print "| ";

For i = 1 To 10
n = Val(InputBox("introduza " & i & "º número", " "))
If n >= 10 And n <= 50 Then
cont1 = cont1 + 1
End If

If n < 10 Or n > 50 Then
cont2 = cont2 + 1
End If

Picture1.Print n & " | ";
Next i

Picture1.Print ""
Picture1.Print "Dentro do intervalo: "; cont1
Picture1.Print "Fora do intervalo: "; cont2

End Sub

Private Sub Command2_Click()

Picture1.Cls

End Sub




Private Sub command1_click()
Dim n As Integer, pares As Integer, cont As Integer, med As Single

cont = 0
soma = 0

For pares = 13 To 73
If pares Mod 2 = 0 Then
npares.Print pares;
soma = soma + pares
cont = cont + 1
End If

If cont = 6 Then
npares.Print Chr(13)
cont = 0
End If
Next pares

med = soma / pares

media.Print Tab(3); Round(med, 0)

End Sub

Private Sub Command2_Click()

End

End Sub




Private Sub Command1_Click()

Dim n As Integer, num As Integer

num = Val(InputBox("Introduza a numero"))

If num = 0 Then
num = MsgBox("Introduza um nº para corresponder á tabuada!", vbOKOnly + vbExclamation, "Informação")
Else
For n = 1 To 10
soma = n * num
Picture1.Print num & " * " & n & " = " & soma
Next n

End If

End Sub



Private Sub cmd1_Click()

Dim n As Integer, soma As Integer, idade As Integer, num As Integer, media As Single

num = Val(InputBox("Quantos alunos são??", "Idades"))
If num = 0 Then
num = MsgBox("Digite um número correspondente ao nº de alunos", vbOKOnly + vbInformation, "Informação")
Else
For n = 1 To num
idade = Val(InputBox("Introduza a " & n & "º idade", "Idades"))
soma = soma + idade
If idade = 0 Then
MsgBox "Introduza uma idade válida", vbOKOnly + vbInformation, "Informação"
End If
Next n

media = soma / num

Picture1.Print "A média das idades da turma de " & num & " é: " & media
Picture1.Print ""
If idade = 0 Then
Picture1.Cls
End If
End If
End Sub

Private Sub cmd2_Click()

Picture1.Cls

End Sub



Private Sub Command1_Click()

Dim num As Integer, soma As Integer, n As Integer

num = Val(InputBox("Introduza um numero!", "Form1"))
If num = 0 Then
MsgBox "Digite um número válido", vbOKOnly + vbInformation, "Informação"
End If
For n = 1 To num
If num Mod n = 0 Then
Picture1.Print n;
soma = soma + n
End If
Next n

Picture1.Print ""

End Sub

Private Sub Command2_Click()

Picture1.Cls

End Sub




Private Sub Command1_Click()

Dim num As Integer, soma As Integer, n As Integer

For n = 4 To 100
If n Mod 4 = 0 Then
Picture1.Print n;
soma = soma + n
End If
Next n

End Sub



Private Sub cmd2_Click()

Dim num As Integer, soma As Integer, n As Integer

For n = 7 To 200
If n Mod 7 = 0 Then
Picture1.Print n;
End If
Next n

End Sub




Private Sub cmd1_Click()

Dim n As Integer, i As Integer

For i = 1 To 100
n = n + i
Next i

Picture1.Print Tab(6); n

End Sub

sábado, 21 de novembro de 2009

Ficha 13-5





Private Sub cmd1_Click()

Dim num As Integer, soma As Integer, n As Integer, x As Integer

minimo = 1000

num = Val(InputBox("Quantos valores quer inserir?", "Caixa de entrada de valores!"))

For n = 1 To num
x = Val(InputBox("introduza o " & n & "º valor", "Caixa de entrada de valores!"))
If x < minimo Then
minimo = x
End If
Next n

Picture1.Print "O menor número introduzido foi -> " & minimo

End Sub

Ficha 13-4





Private Sub cmd1_Click()

Dim num As Integer, soma As Integer, n As Integer

num = Val(InputBox("Introduza um numero", "Caixa de entrada"))
Picture1.Print "Múltiplos -> ";
For n = 1 To num
If n Mod 5 = 0 Then
Picture1.Print n;
soma = soma + n
End If
Next n

Picture1.Print
Picture1.Print "Soma dos números múltiplos de 5 -> " & soma

End Sub

Private Sub Limpar_Click()
Picture1.Cls
End Sub

Private Sub Sair_Click()
End
End Sub

Ficha 13-3





Private Sub cmd1_Click()
Dim n As Integer, x As Integer, multi As Single

mult = 1

x = Val(InputBox("Introduza um valor", "Iniciar"))
For n = 1 To x
Picture1.Print n;
mult = mult * n
Next n

Picture1.Print ""
Picture1.Print "Número -> " & x
Picture1.Print "Produto -> " & mult

End Sub

Private Sub Limpar_Click()
Picture1.Cls
End Sub

Private Sub Sair_Click()
End
End Sub

Ficha 13-2



Private Sub cmd1_Click()
Dim n As Integer, soma As Single, cont As Single

cont = 0

For n = 86 To 907 Step 2
soma = soma + n
cont = cont + 1
Next n

Picture1.Print " A soma dos números pares entre 85 e 907 é de " & soma
Picture1.Print " Existe " & cont & " números pares entre 85 e 907 "

End Sub

Private Sub Sair_Click()
End
End Sub

Ficha 13-1





Private Sub cmd1_Click()
Dim n As Integer, soma As Integer, negativos As Integer
Dim cont As Integer

cont = 0
soma = 0
negativos = 0


MsgBox "Introduza 10 números á sua escolha", vbOKCancel + vbInformation, "Programa"

For n = 1 To 10
cont = cont + 1

numero = InputBox("Introduza o " & cont & "º número inteiro", "Introduzir números")
If numero = 0 Then
End
End If

Picture1.Print cont & "º número ->" & numero

If numero > 0 Then
soma = soma + numero
ElseIf numero < 0 Then
negativos = negativos + 1
End If

Next n

Picture1.Print "Soma dos números positivos -> " & soma
Picture1.Print "Número de negativos -> " & negativos

End Sub

Private Sub Limpar_Click()
Picture1.Cls
End Sub

Private Sub Sair_Click()
End
End Sub