sábado, 21 de novembro de 2009

Ficha 12-1





Private Sub cmd_Click()

Dim n As Single

x = Val(InputBox("Insira o código"))

n = Val(InputBox("Insira o ordenado"))

If x = 0 Or n = 0 Then
x = MsgBox("Introduza valores válidos!", vbOKOnly + vbExclamation, "Informação")
codigo = ""
cargo = ""
percentagem = ""
antigo = ""
novo = ""
diferenca = ""
ElseIf x = 101 Then
codigo = x
cargo = "Gerente"
percentagem = "10%"
antigo = n & "€"
novo = (n * 10 / 100) + n & "€"
diferenca = n * 10 / 100 & "€"
ElseIf x = 102 Then
codigo = x
cargo = "Engenheiro"
percentagem = "20%"
antigo = n & "€"
novo = (n * 20 / 100) + n & "€"
diferenca = n * 20 / 100 & "€"
ElseIf x = 103 Then
codigo = x
cargo = "Técnico"
percentagem = "30%"
antigo = n & "€"
novo = (n * 30 / 100) + n & "€"
diferenca = n * 30 / 100 & "€"
Else
codigo = x
cargo = "Outro Cargo"
percentagem = "40%"
antigo = n & "€"
novo = (n * 40 / 100) + n & "€"
diferenca = n * 40 / 100 & "€"
End If

End Sub

Private Sub Limpar_Click()
codigo = ""
cargo = ""
percentagem = ""
antigo = ""
novo = ""
diferenca = ""
End Sub

Private Sub Sair_Click()
End
End Sub

segunda-feira, 16 de novembro de 2009

Ficha 11-4





Private Sub cmd1_Click()

Dim aleatorio1 As Integer, n As Integer, cont As Integer

cont = 0

n = Val(InputBox("Insira a sua tentativa"))
If n = 0 Then
resultado = ""
MsgBox "Programa terminado.."
End
End If
Randomize
aleatorio1 = Int(Rnd() * 5) + 1

Do

If aleatorio1 <> n Then
cont = cont + 1
resultado.Caption = "Tente outravez"
n = Val(InputBox("Insira a sua tentativa"))
resultado.Caption = ""
End If
If aleatorio1 = n Then
cont = cont + 1
resultado.Caption = "Acertou!"
tentativas.Caption = cont
MsgBox "Parabéns, Acertou! em " & cont & " tentativas"
End If
Loop Until aleatorio1 = n Or n = 0

End Sub

Private Sub cmd2_Click()
End
End Sub

Ficha 11-3





Private Sub cmd1_Click()

Dim aleatorio1 As Integer, n As Integer


n = Val(InputBox("Insira a sua tentativa"))
If n = 0 Then
resultado = ""
MsgBox "Programa terminado.."
End
End If
Randomize
aleatorio1 = Int(Rnd() * 5) + 1

Do

If aleatorio1 <> n Then
resultado.Caption = "Tente outravez"
n = Val(InputBox("Insira a sua tentativa"))
resultado.Caption = ""
End If
If aleatorio1 = n Then
resultado.Caption = "Acertou!"
MsgBox "Parabéns, Acertou!"
End If
Loop Until aleatorio1 = n Or n = 0

End Sub

Private Sub cmd2_Click()
End
End Sub

Ficha 11-2





Private Sub cmd1_Click()

Dim n As Integer, soma As Integer, cont As Integer, contp As Integer

contp = 0

num = Val(InputBox("Quantas chaves quer que sejam mostradas?"))
If num = 0 Then
End

End If
Randomize
Do
Picture1.Print contp + 1; "ª sequência ->";
cont = 0

Do
n = Int(Rnd() * 49) + 1
cont = cont + 1
Picture1.Print n;
Loop Until cont = 6

contp = contp + 1
Picture1.Print Chr(13)
Loop Until contp = 7 Or contp = num




End Sub

Private Sub cmd2_Click()
End
End Sub

Ficha 11-1





Private Sub cmd1_Click()

Dim aleatorio1 As Integer, cont As Integer

cont = 0

MsgBox "Irão ser gerados 6 números aleatórios!", vbOKOnly + vbInformation, "Números"

Randomize
Picture1.Print "Números ->";
Do
aleatorio1 = Int(Rnd() * 49) + 1
cont = cont + 1
Picture1.Print aleatorio1;
Loop Until cont = 6

End Sub

Private Sub cmd2_Click()

If MsgBox("Tem a certeza que quer sair?", vbOKCancel, "Sair") = vbOK Then End

End Sub

sexta-feira, 6 de novembro de 2009

Ficha 10-3








Private Sub cmd1_Click()

Dim aleatorio As Integer
Picture1.Picture = LoadPicture("")
Picture1.Cls
Randomize
aleatorio1 = Int(Rnd() * 9)
Randomize
aleatorio2 = Int(Rnd() * 9)
Randomize
aleatorio3 = Int(Rnd() * 9)


If (aleatorio1 <> 7 And aleatorio2 <> 7) Or (aleatorio2 <> 7 And aleatorio3 <> 7) Or (aleatorio1 <> 7 And aleatorio3 <> 7) Then
Picture1.Print " Tente outra vez.. "
numero1.Caption = aleatorio1
numero2.Caption = aleatorio2
numero3.Caption = aleatorio3
ElseIf (aleatorio1 = 7 And aleatorio2 = 7 And aleatorio3 = 7) Then
Picture1.Picture = LoadPicture("C:\Users\Florindo\Documents\João Florindo\Trabalhos 2009;2010\Programação\Ficha10 Programa\Ficha10-3\jackpot2.gif")
numero1.Caption = aleatorio1
numero2.Caption = aleatorio2
numero3.Caption = aleatorio3
ElseIf (aleatorio1 = 7 And aleatorio2 = 7) Or (aleatorio2 = 7 And aleatorio3 = 7) Or (aleatorio1 = 7 And aleatorio3 = 7) Then
Picture1.Picture = LoadPicture("C:\Users\Florindo\Documents\João Florindo\Trabalhos 2009;2010\Programação\Ficha10 Programa\Ficha10-3\gold-coins-images.jpeg")
numero1.Caption = aleatorio1
numero2.Caption = aleatorio2
numero3.Caption = aleatorio3

End If

End Sub

Private Sub cmd2_Click()
End
End Sub

Ficha 9-4





Private Sub cmd1_Click()


Dim valor As Single, cont As Single

valor = 0
cont = 0

MsgBox "Para terminar as suas compras faça cancel ou digite o valor '0' ", vbOKOnly + 64, "Informação"

Do
valor = Val(InputBox("Introduza o valor do " & cont + 1 & "º produto"))
If valor > 0 Then
soma = soma + valor
cont = cont + 1
End If
Loop While valor <> 0

End Sub

Private Sub cmd2_Click()
If soma = 0 Then
resultado.Caption = ""
MsgBox "Faça as suas compras", vbOKOnly + 48, "Informação"
Else
result1 = soma - (soma * 10 / 100)
resultado.Caption = "O total a pagar é " & Round(result1, 2) & "€"
MsgBox "Sem um desconto de 10% pagava " & soma & "€", vbOKOnly + 64, "Informação"
End If
End Sub

Private Sub cmd3_Click()

If soma = 0 Then
resultado.Caption = ""
MsgBox "Faça as suas compras", vbOKOnly + 48, "Informação"
Else
result1 = soma - (soma * 5 / 100)
resultado.Caption = "O total a pagar é " & Round(result1, 2) & "€"
MsgBox "Sem um desconto de 5% pagava " & soma & "€", vbOKOnly + 64, "Informação"
End If
End Sub

Private Sub cmd4_Click()
If soma = 0 Then
resultado.Caption = ""
MsgBox "Faça as suas compras", vbOKOnly + 48, "Informação"
Else
result1 = soma / 2
resultado.Caption = "O valor a pagar em 2x sem juros é " & Round(result1, 2) & "€"
MsgBox "O total que vai ter a pagar é " & soma & "€", vbOKOnly + 64, "Informação"
End If
End Sub

Private Sub cmd5_Click()
If soma = 0 Then
resultado.Caption = ""
MsgBox "Faça as suas compras", vbOKOnly + 48, "Informação"
Else
result1 = (soma + (soma * 10 / 100)) / 3
resultado.Caption = "O valor a pagar em 3x com 10% de juros é " & Round(result1, 2) & "€"
MsgBox "O total que vai ter de pagar é " & Round(result1 * 3, 2) & "€", vbOKOnly + 64, "Informação"
End If
End Sub


Private Sub Sair_Click()
MsgBox "Obrigado pela sua visita ;)", 0, "Compras"
End
End Sub

Private Sub Timer1_Timer()
hora = Time
End Sub