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

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