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

Ficha 6




Private Sub cmd1_Click()

Dim a As Single, b As Single, c As Single

a = Val(oper1.Text)
b = Val(oper2.Text)
c = Val(oper3.Text)

If 2 * a = 0 Then
obs.Caption = "Não tem soluções"
raiz1.Caption = ""
raiz2.Caption = ""
ElseIf b ^ 2 - 4 * a * c = 0 Then
obs.Caption = "Só tem uma solução"
raiz1.Caption = Round(-b / (2 * a), 2)
raiz2.Caption = ""
ElseIf b ^ 2 - 4 * a * c > 0 Then
raiz1.Caption = Round(-b + Sqr(b ^ 2 - (4 * a * c)) / (2 * a), 2)
raiz2.Caption = Round(-b - Sqr(b ^ 2 - (4 * a * c)) / (2 * a), 2)
obs.Caption = ""
Else
obs.Caption = "Não tem soluções em R"
raiz1.Caption = ""
raiz2.Caption = ""
End If

End Sub

Private Sub Sair_Click()
End
End Sub

sexta-feira, 16 de outubro de 2009

Ficha5-5

Imagem1


Imagem2


Private Sub cmd1_Click()

Dim a As Single, b As Single, c As Single, x As Single, y As Single, z As Single

x = Val(operA.Text)
y = Val(operB.Text)
z = Val(operC.Text)

If x > y And x > z Then
a = x
b = y
c = z
ElseIf y > x And y > z Then
a = y
b = x
c = z
ElseIf z > x And z > y Then
a = z
b = x
c = y
Else
a = x
b = y
c = z
End If


If a >= b + c Then
resultado.Caption = "Nenhum triângulo formado"
Image1.Visible = False
Image2.Visible = False
Image3.Visible = False
Image4.Visible = True

ElseIf a ^ 2 = b ^ 2 + c ^ 2 Then
resultado.Caption = "Triângulo retângulo"
Image1.Visible = True
Image2.Visible = False
Image3.Visible = False
Image4.Visible = False

ElseIf a ^ 2 > b ^ 2 + c ^ 2 Then
resultado.Caption = "Triângulo obtusângulo"
Image1.Visible = False
Image2.Visible = True
Image3.Visible = False
Image4.Visible = False

ElseIf a ^ 2 < b ^ 2 + c ^ 2 Then
resultado.Caption = "Triângulo acutângulo"
Image1.Visible = False
Image2.Visible = False
Image3.Visible = True
Image4.Visible = False

End If

End Sub

Private Sub cmd2_Click()
End
End Sub

Ficha5-4



Private Sub cmd1_Click()
Dim a As Single, b As Single, c As Single

a = Val(operA.Text)
b = Val(operB.Text)
c = Val(operC.Text)

If a = b And c = a And b = c Then
resultado1.Caption = "Triangulo Equilátero"
resultado2.Caption = " "
resultado3.Caption = ""
ElseIf b = a Or c = a Or b = c Then
resultado2.Caption = "Triangulo Isósceles"
resultado1.Caption = " "
resultado3.Caption = " "
Else
resultado3.Caption = "Triangulo Escaleno"
resultado1.Caption = " "
resultado2.Caption = " "
End If

End Sub

Ficha5-3



Private Sub cmd1_Click()
Dim a As Single, b As Single, c As Single

a = Val(operA.Text)
b = Val(operB.Text)
c = Val(operC.Text)

If a < b + c And b < a + c And c < a + b Then
resultado1.Caption = "É um Triângulo"
resultado2.Caption = " "
Else
resultado1.Caption = " "
resultado2.Caption = "Não é um Triângulo"
End If

End Sub

Private Sub cmd2_Click()
End
End Sub

Ficha5-2



Private Sub cmd1_Click()
resultado.Caption = Val(oper1.Text) Mod 3

If resultado.Caption = 0 Then
resultado.Caption = "É multiplo de 3"
Else
resultado.Caption = "Não é multiplo de 3"

End If
End Sub

Private Sub cmd2_Click()
resultado.Caption = Val(oper1.Text) Mod 5

If resultado.Caption = 0 Then
resultado.Caption = "É multiplo de 5"
Else
resultado.Caption = "Não é multiplo de 5"
End If

End Sub

Private Sub cmd3_Click()

resultado.Caption = (Val(oper1.Text) Mod 3) + (Val(oper1.Text) Mod 5) / 2


If resultado.Caption = 0 Then
resultado.Caption = "É multiplo de 3 e 5"
Else
resultado.Caption = "Não é multiplo de 3 e 5"
End If

End Sub
Private Sub cmd4_Click()
End
End Sub

Ficha5-1



Private Sub cmd1_Click()
resultado.Caption = Val(oper1.Text) Mod 2

If resultado.Caption = 0 Then
resultado.Caption = "Par"
Else
resultado.Caption = "Impar"
End If

End Sub

Private Sub cmd2_Click()
End
End Sub

sexta-feira, 9 de outubro de 2009

Ficha 4-2

A pedido de correcção da senhora professora, que acha que o trabalho estava um pouco incompleto aqui está a emenda ..
Private Sub cmd1_Click()

If Val(oper1.Text) < 0 Or Val(oper1.Text) > 20 Or Val(oper2.Text) < 0 Or Val(oper2.Text) > 20 Or Val(oper3.Text) < 0 Or Val(oper3.Text) > 20 Then
situacao.Caption = "Erro"
resultado.Caption = " "
Else

If Val(oper1.Text) < 6.5 Or Val(oper2.Text) < 6.5 Or Val(oper3.Text) < 6.5 Then
situacao.Caption = "Reprovado"
resultado.Caption = " "
Else
resultado.Caption = (Round((Val(oper1.Text) + Val(oper2.Text) + Val(oper3.Text)) / 3, 1))
If resultado < 10 Then
situacao.Caption = "reprovado"
ElseIf resultado >= 10 And resultado < 14 Then
situacao.Caption = "suficiente"
ElseIf resultado >= 14 And resultado < 16 Then
situacao.Caption = "bom"
ElseIf resultado >= 16 And resultado < 18 Then
situacao.Caption = "Bom"
ElseIf resultado >= 18 Then
situacao.Caption = "Muito Bom"
End If
End If
End If

End Sub

Private Sub cmd2_Click()
End
End Sub

Ficha 4-1



Const Base = 1500

Private Sub cmd1_Click()
End
End Sub

Private Sub cmd2_Click()
preco.Caption = Base * Val(quantidade.Text)

If (quantidade.Text) >= 1000 Then
desconto = 8
ElseIf (quantidade.Text) >= 100 Then
desconto = 5
Else
desconto = 0
End If

If desconto = 8 Then
quociente.Caption = preco.Caption Mod (preco.Caption - (Val(preco) * 8 / 100))
ElseIf desconto = 5 Then
quociente.Caption = preco.Caption Mod (preco.Caption - (Val(preco) * 5 / 100))
Else
quociente.Caption = 0
End If

If desconto = 8 Then
preco.Caption = preco.Caption - (Val(preco) * 8 / 100)
ElseIf desconto = 5 Then
preco.Caption = preco.Caption - (Val(preco) * 5 / 100)
End If

End Sub

sexta-feira, 2 de outubro de 2009

Ficha3-5


Private Sub cmd_Click()
Fahrenheit.Caption = 9 / 5 * (Celsius.Text) + 32
End Sub

Private Sub sinal_Click()
End
End Sub

Ficha3-4

Private Sub cmd_Click()
area.Caption = PI * (raio.Text) ^ 2
End Sub

Private Sub Command1_Click()
End
End Sub

Ficha3-3


Private Sub cmd_Click()
area.Caption = Val(base.Text) * Val(altura.Text)
perimetro.Caption = 2 * Val(base.Text) + 2 * Val(altura.Text)
End Sub

Private Sub cmd2_Click()
End
End Sub

Ficha3-2


Private Sub Cmdigual_Click()
Resultado.Caption = Val(oper1.Text) / Val(oper2.Text)
Resultado2.Caption = Val(oper1.Text) Mod Val(oper2.Text)
End Sub

Private Sub cmdsair_Click()
End
End Sub

Ficha3-1


Private Sub cmd_Click()
resultado1.Caption = Val(oper1.Text) + Val(oper2.Text) + Val(oper3.Text)
resultado2.Caption = resultado1.Caption / 3
End Sub



Private Sub Cmd2_Click()
End
End Sub

quinta-feira, 1 de outubro de 2009

Ficha 2


Private Sub cmdsair_Click()
End
End Sub

Private Sub cmdsinal1_Click()
Resultado2.Caption = Val(oper1.Text) + Val(oper2.Text)
End Sub

Private Sub cmdsinal2_Click()
Resultado2.Caption = Val(oper1.Text) - Val(oper2.Text)
End Sub

Private Sub cmdsinal3_Click()
Resultado2.Caption = Val(oper1.Text) * Val(oper2.Text)
End Sub

Private Sub cmdsinal4_Click()
Resultado2.Caption = Val(oper1.Text) / Val(oper2.Text)
End Sub