sexta-feira, 30 de outubro de 2009

Ficha 9-1





Private Sub cmd1_Click()

Dim pesos As Integer, soma As Integer, cont As Integer

pesos = 0
soma = 0
cont = 0

Do
pesos = Val(InputBox("Introduza o " & cont + 1 & "º Peso"))
If pesos >= 0 Then
soma = soma + pesos
If pesos = 0 Then
Exit Do
End If

cont = cont + 1

If cont = 6 Or soma >= 450 Then
Exit Do
End If

End If

Loop While cont < 6
resultado.Caption = cont
resultadopeso.Caption = soma

If soma >= 450 Then
resultado.Caption = cont
resultadopeso.Caption = "Peso Excessivo"
End If

End Sub

Private Sub cmd2_Click()
End
End Sub

Ficha 8-4







Private Sub cmd1_Click()

Dim media As Single, maximo As Integer, minimo As Integer
Dim id As Integer, soma As Integer, cont As Integer, contp As Integer

media = 0
maximo = 0
minimo = 100
id = 0
soma = 0
cont = 0
contp = 0

num = Val(InputBox("Quantos valores quer inserir?"))
If num = 0 Then
End
End If

Do
id = Val(InputBox("Introduza o " & cont + 1 & " valor"))
cont = cont + 1
If id > 0 Then
soma = soma + id
contp = contp + 1

If id > maximo Then
maximo = id
End If
If id < minimo Then
minimo = id
End If
End If
Loop While num <> cont
media = Round(soma / contp, 1)
resultado.Print "A soma dos números introduzidos é"; soma
resultado.Print "A média dos " & contp & "º números positivos introduzidos é"; media
resultado.Print "O maior número introduzido foi"; maximo
resultado.Print "O menor número introduzido foi"; minimo

End Sub

Private Sub cmd2_Click()
End
End Sub

Ficha 8-3





Private Sub cmd1_Click()

Dim temp As Integer, soma As Integer, cont As Integer, tempmaior As Integer, tempmenor As Integer, media As Single

media = 0
tempmaior = 0
tempmenor = 100
temp = 0
soma = 0
cont = 0

Do
temp = Val(InputBox("Introduza a " & cont + 1 & "ª temperatura!"))
If temp > -20 Then
soma = soma + temp
cont = cont + 1

If temp > tempmaior Then
tempmaior = temp

End If
If temp < tempmenor Then
tempmenor = temp
End If

End If
Loop While cont < 12
media = Round(soma / cont, 1)
resultado.Print "A média das temperaturas no Porto é de:"; media
resultado.Print "A temperatura mais alta no Porto é"; tempmaior
resultado.Print "A temperatura mais baixa no Porto é"; tempmenor
End Sub

Private Sub cmd2_Click()
End
End Sub

Ficha 8-1




Private Sub cmd1_Click()

Dim n1 As Integer, n2 As Integer, soma As Integer

n1 = Val(oper1.Text)
n2 = Val(oper2.Text)

If n1 < 0 Or n2 < 0 Then
resultado.Print "Erro"
ElseIf n1 < n2 Then
n1 = n1 + 1
Do
soma = soma + n1
n1 = n1 + 1
Loop Until n1 = n2
resultado.Print soma
ElseIf n1 = n2 Then
resultado.Print "Não há valores a somar"
Else
n2 = n2 + 1
Do
soma = soma + n2
n2 = n2 + 1
Loop Until n1 = n2
resultado.Print soma
End If

End Sub

Private Sub cmd2_Click()
End
End Sub

sexta-feira, 23 de outubro de 2009

Ficha 7-3




Private Sub cmd1_Click()

Dim media As Single, inf14 As Integer, inf18 As Integer
Dim igual18 As Integer, iddmaior As Integer, dados As Integer
Dim id As Integer, soma As Integer, cont As Integer
media = 0
inf14 = 0
inf18 = 0
igual18 = 0
iddmaior = 0
dados = 0
id = 0
soma = 0
cont = 0


Do
id = Val(InputBox("Introduza o valor"))
If id > 0 Then
soma = soma + id
cont = cont + 1
If id < 14 Then
inf14 = inf14 + 1
ElseIf id >= 14 And id < 18 Then
inf18 = inf18 + 1
Else
igual18 = igual18 + 1
End If

If id > iddmaior Then
iddmaior = id
End If
End If
Loop While id <> 0
media = Round(soma / cont, 1)
lblmedia.Caption = media
lblinf14.Caption = inf14
lblinf18.Caption = inf18
lbligual18.Caption = igual18
lbliddmaior.Caption = iddmaior
lbldados.Caption = cont



End Sub

Private Sub cmd2_Click()
End
End Sub

Private Sub Timer1_Timer()
hora = Time
End Sub

Ficha 7-2




Private Sub cmd1_Click()

Dim n As Integer, soma As Integer, cont As Integer, impar As Integer

n = Val(oper1.Text)
soma = 0
cont = 1
impar = 1

Do While cont <= n
soma = soma + impar
impar = impar + 2
cont = cont + 1
Loop
resultado.Caption = "A soma dos " & n & " números ímpares é " & soma

End Sub

Private Sub Limpar_Click()
oper1.Text = ""
resultado.Caption = ""
End Sub

Private Sub Sair_Click()
End
End Sub

Ficha 7-1




Private Sub cmd1_Click()

Dim n As Integer, m As Integer, soma As Integer, mult As Integer, cont As Integer

n = Val(oper1.Text)
m = Val(oper2.Text)
cont = 1
soma = 0

Do While n > 0
mult = cont * m
soma = soma + mult
cont = cont + 1
n = n - 1
Loop
resultado.Caption = "A soma dos " & cont - 1 & " primeiros múltiplos de " & m & " é " & soma

End Sub

Private Sub Limpar_Click()
oper1.Text = ""
oper2.Text = ""
resultado = ""
End Sub


Private Sub Sair_Click()
End
End Sub