quinta-feira, 17 de dezembro de 2009

Ficha 17-5



Private Sub Timer1_Timer()

Lbltime.Caption = Now()

End Sub

Function FU_Delay(Quanto As Double, PermiteDoEvents As Integer) As Double

Dim inicio As Double
Dim Check As Double
Dim Contador As Double
Contador = Timer
inicio = Timer
Do Until Check >= (inicio + Quanto)
Check = Timer
If PermiteDoEvents Then DoEvents
Loop

FU_Delay = (Timer - Contador)
End Function

Private Sub Form_Load()
Form3.Show
Form2.Hide
If res = sair Then
r = FU_Delay(3, True)
Beep
End
End If
End Sub




Private Sub Command1_Click()
Image1.Visible = True
Image2.Visible = False
Image3.Visible = False
Image4.Visible = False
Image5.Visible = False
Image6.Visible = False
Image7.Visible = False
Image8.Visible = False
Image9.Visible = False
Image10.Visible = False
Image11.Visible = False
Image12.Visible = False
Image13.Visible = False
Image14.Visible = False
Image15.Visible = False
Image16.Visible = False
Image17.Visible = False
Image18.Visible = False
End Sub

Private Sub Command10_Click()
Image1.Visible = False
Image2.Visible = False
Image3.Visible = False
Image4.Visible = False
Image5.Visible = False
Image6.Visible = False
Image7.Visible = False
Image8.Visible = False
Image9.Visible = False
Image10.Visible = True
Image11.Visible = False
Image12.Visible = False
Image13.Visible = False
Image14.Visible = False
Image15.Visible = False
Image16.Visible = False
Image17.Visible = False
Image18.Visible = False
End Sub

Private Sub Command11_Click()
Image1.Visible = False
Image2.Visible = False
Image3.Visible = False
Image4.Visible = False
Image5.Visible = False
Image6.Visible = False
Image7.Visible = False
Image8.Visible = False
Image9.Visible = False
Image10.Visible = False
Image11.Visible = True
Image12.Visible = False
Image13.Visible = False
Image14.Visible = False
Image15.Visible = False
Image16.Visible = False
Image17.Visible = False
Image18.Visible = False
End Sub

Private Sub Command12_Click()
Image1.Visible = False
Image2.Visible = False
Image3.Visible = False
Image4.Visible = False
Image5.Visible = False
Image6.Visible = False
Image7.Visible = False
Image8.Visible = False
Image9.Visible = False
Image10.Visible = False
Image11.Visible = False
Image12.Visible = True
Image13.Visible = False
Image14.Visible = False
Image15.Visible = False
Image16.Visible = False
Image17.Visible = False
Image18.Visible = False
End Sub

Private Sub Command13_Click()
Image1.Visible = False
Image2.Visible = False
Image3.Visible = False
Image4.Visible = False
Image5.Visible = False
Image6.Visible = False
Image7.Visible = False
Image8.Visible = False
Image9.Visible = False
Image10.Visible = False
Image11.Visible = False
Image12.Visible = False
Image13.Visible = True
Image14.Visible = False
Image15.Visible = False
Image16.Visible = False
Image17.Visible = False
Image18.Visible = False
End Sub

Private Sub Command14_Click()
Image1.Visible = False
Image2.Visible = False
Image3.Visible = False
Image4.Visible = False
Image5.Visible = False
Image6.Visible = False
Image7.Visible = False
Image8.Visible = False
Image9.Visible = False
Image10.Visible = False
Image11.Visible = False
Image12.Visible = False
Image13.Visible = False
Image14.Visible = True
Image15.Visible = False
Image16.Visible = False
Image17.Visible = False
Image18.Visible = False
End Sub

Private Sub Command15_Click()
Image1.Visible = False
Image2.Visible = False
Image3.Visible = False
Image4.Visible = False
Image5.Visible = False
Image6.Visible = False
Image7.Visible = False
Image8.Visible = False
Image9.Visible = False
Image10.Visible = False
Image11.Visible = False
Image12.Visible = False
Image13.Visible = False
Image14.Visible = False
Image15.Visible = True
Image16.Visible = False
Image17.Visible = False
Image18.Visible = False
End Sub

Private Sub Command16_Click()
Image1.Visible = False
Image2.Visible = False
Image3.Visible = False
Image4.Visible = False
Image5.Visible = False
Image6.Visible = False
Image7.Visible = False
Image8.Visible = False
Image9.Visible = False
Image10.Visible = False
Image11.Visible = False
Image12.Visible = False
Image13.Visible = False
Image14.Visible = False
Image15.Visible = False
Image16.Visible = True
Image17.Visible = False
Image18.Visible = False
End Sub

Private Sub Command17_Click()
Image1.Visible = False
Image2.Visible = False
Image3.Visible = False
Image4.Visible = False
Image5.Visible = False
Image6.Visible = False
Image7.Visible = False
Image8.Visible = False
Image9.Visible = False
Image10.Visible = False
Image11.Visible = False
Image12.Visible = False
Image13.Visible = False
Image14.Visible = False
Image15.Visible = False
Image16.Visible = False
Image17.Visible = True
Image18.Visible = False
End Sub

Private Sub Command18_Click()
Image1.Visible = False
Image2.Visible = False
Image3.Visible = False
Image4.Visible = False
Image5.Visible = False
Image6.Visible = False
Image7.Visible = False
Image8.Visible = False
Image9.Visible = False
Image10.Visible = False
Image11.Visible = False
Image12.Visible = False
Image13.Visible = False
Image14.Visible = False
Image15.Visible = False
Image16.Visible = False
Image17.Visible = False
Image18.Visible = True
End Sub

Private Sub Command19_Click()

Form1.Show
Form4.Hide

End Sub

Private Sub Command2_Click()
Image1.Visible = False
Image2.Visible = True
Image3.Visible = False
Image4.Visible = False
Image5.Visible = False
Image6.Visible = False
Image7.Visible = False
Image8.Visible = False
Image9.Visible = False
Image10.Visible = False
Image11.Visible = False
Image12.Visible = False
Image13.Visible = False
Image14.Visible = False
Image15.Visible = False
Image16.Visible = False
Image17.Visible = False
Image18.Visible = False
End Sub

Private Sub Command20_Click()
Dim confirmacao As Integer

confirmacao = MsgBox("Pretende mesmo sair?", vbYesNo + vbQuestion, "Deutsch-Fraktion - Confirmação")

If confirmacao = vbYes Then
Form3.Show
Form4.Hide
Else
End If

End Sub

Private Sub Command3_Click()
Image1.Visible = False
Image2.Visible = False
Image3.Visible = True
Image4.Visible = False
Image5.Visible = False
Image6.Visible = False
Image7.Visible = False
Image8.Visible = False
Image9.Visible = False
Image10.Visible = False
Image11.Visible = False
Image12.Visible = False
Image13.Visible = False
Image14.Visible = False
Image15.Visible = False
Image16.Visible = False
Image17.Visible = False
Image18.Visible = False
End Sub

Private Sub Command4_Click()
Image1.Visible = False
Image2.Visible = False
Image3.Visible = False
Image4.Visible = True
Image5.Visible = False
Image6.Visible = False
Image7.Visible = False
Image8.Visible = False
Image9.Visible = False
Image10.Visible = False
Image11.Visible = False
Image12.Visible = False
Image13.Visible = False
Image14.Visible = False
Image15.Visible = False
Image16.Visible = False
Image17.Visible = False
Image18.Visible = False
End Sub

Private Sub Command5_Click()
Image1.Visible = False
Image2.Visible = False
Image3.Visible = False
Image4.Visible = False
Image5.Visible = True
Image6.Visible = False
Image7.Visible = False
Image8.Visible = False
Image9.Visible = False
Image10.Visible = False
Image11.Visible = False
Image12.Visible = False
Image13.Visible = False
Image14.Visible = False
Image15.Visible = False
Image16.Visible = False
Image17.Visible = False
Image18.Visible = False
End Sub

Private Sub Command6_Click()
Image1.Visible = False
Image2.Visible = False
Image3.Visible = False
Image4.Visible = False
Image5.Visible = False
Image6.Visible = True
Image7.Visible = False
Image8.Visible = False
Image9.Visible = False
Image10.Visible = False
Image11.Visible = False
Image12.Visible = False
Image13.Visible = False
Image14.Visible = False
Image15.Visible = False
Image16.Visible = False
Image17.Visible = False
Image18.Visible = False
End Sub

Private Sub Command7_Click()
Image1.Visible = False
Image2.Visible = False
Image3.Visible = False
Image4.Visible = False
Image5.Visible = False
Image6.Visible = False
Image7.Visible = True
Image8.Visible = False
Image9.Visible = False
Image10.Visible = False
Image11.Visible = False
Image12.Visible = False
Image13.Visible = False
Image14.Visible = False
Image15.Visible = False
Image16.Visible = False
Image17.Visible = False
Image18.Visible = False
End Sub

Private Sub Command8_Click()
Image1.Visible = False
Image2.Visible = False
Image3.Visible = False
Image4.Visible = False
Image5.Visible = False
Image6.Visible = False
Image7.Visible = False
Image8.Visible = True
Image9.Visible = False
Image10.Visible = False
Image11.Visible = False
Image12.Visible = False
Image13.Visible = False
Image14.Visible = False
Image15.Visible = False
Image16.Visible = False
Image17.Visible = False
Image18.Visible = False
End Sub

Private Sub Command9_Click()
Image1.Visible = False
Image2.Visible = False
Image3.Visible = False
Image4.Visible = False
Image5.Visible = False
Image6.Visible = False
Image7.Visible = False
Image8.Visible = False
Image9.Visible = True
Image10.Visible = False
Image11.Visible = False
Image12.Visible = False
Image13.Visible = False
Image14.Visible = False
Image15.Visible = False
Image16.Visible = False
Image17.Visible = False
Image18.Visible = False
End Sub




Private Sub cmd1_Click()

Dim matriz(1 To 3, 1 To 4), vendedor As Integer, trimestre As Integer, cont As Integer
Dim soma As Integer, i As Integer, total As Integer, total2 As Integer
Dim totalvendedor(1 To 3) As Integer, totaltrimestre(1 To 4) As Integer

cont = 0
total = 0
total2 = 0

' Preenchimento da matriz com números introduzidos pelo utilizador

For vendedor = 1 To 3
If vendedor = 1 Then
tipo = "Audi"
End If
If vendedor = 2 Then
tipo = "BMW"
End If
If vendedor = 3 Then
tipo = "Mercedes-Benz"
End If
Picture1.Print tipo
Picture1.Print "||";
For trimestre = 1 To 4
matriz(vendedor, trimestre) = Val(InputBox("Introduza as vendas da " & tipo & " no " & trimestre & "º Trimestre", "Notas"))
Picture1.Print matriz(vendedor, trimestre); "||";
cont = cont + 1
soma = soma + matriz(vendedor, trimestre)
If cont = 4 Then
Picture1.Print Chr(13);
cont = 0
End If
Next trimestre
Next vendedor

' Pesquisa do total de vendas de cada vendedor

For vendedor = 1 To 3
total2 = 0
For trimestre = 1 To 4
total = total + matriz(vendedor, trimestre)
total2 = total2 + matriz(vendedor, trimestre)
Next trimestre
If vendedor = 1 Then
tipo = "Audi"
End If
If vendedor = 2 Then
tipo = "BMW"
End If
If vendedor = 3 Then
tipo = "Mercedes-Benz"
End If
totalvendedor(vendedor) = total2
Picture2.Print "Venda de automóveis " & tipo & " -> " & totalvendedor(vendedor) & " unidades vendidas."
Next vendedor

' Pesquisa do total de vendas de cada trimestre

For trimestre = 1 To 4
total2 = 0
For vendedor = 1 To 3
total2 = total2 + matriz(vendedor, trimestre)
Next vendedor
totaltrimestre(trimestre) = total2
Picture3.Print trimestre & "ºtrimestre " & totaltrimestre(trimestre)
Next trimestre

Picture4.Print "O total de vendas das 3 marcas de automóveis -> " & soma & " unidades vendidas num ano."

cmd1.Enabled = False

End Sub

Private Sub Command1_Click()

Form1.Show
Form2.Hide

End Sub

Private Sub sair_click()
Dim confirmacao As Integer

confirmacao = MsgBox("Pretende mesmo sair?", vbYesNo + vbQuestion, "Deutsch-Fraktion - Confirmação")

If confirmacao = vbYes Then
Form3.Show
Form2.Hide
Else
End If

End Sub





Private Sub Command1_Click()

Form2.Show
Form1.Hide

End Sub

Private Sub Command2_Click()

Form4.Show
Form1.Hide

End Sub

Private Sub sair_click()
Dim confirmacao As Integer

confirmacao = MsgBox("Pretende sair?", vbYesNo + vbQuestion, "Deutsch-Fraktion - Confirmação")

If confirmacao = vbYes Then
Form3.Show
Form2.Hide
Else
End If

End Sub

quarta-feira, 16 de dezembro de 2009

Ficha 17-4



Private Sub cmd1_Click()

Dim matriz(1 To 4, 1 To 4), linha As Integer, coluna As Integer, cont As Integer
Dim vetA(1 To 4) As Integer, vetB(1 To 4) As Integer

Picture1.Cls
Picture2.Cls
Picture3.Cls
cont = 0

Randomize

For linha = 1 To 4
For coluna = 1 To 4
matriz(linha, coluna) = Int(Rnd() * 10)
Picture1.Print matriz(linha, coluna);
cont = cont + 1
If cont = 4 Then
Picture1.Print Chr(13)
cont = 0
End If
Next coluna
Next linha

For linha = 1 To 4
vetA(linha) = 0
For coluna = 1 To 4
If matriz(linha, coluna) > vetA(linha) Then
vetA(linha) = matriz(linha, coluna)
End If
Next coluna
Next linha

For coluna = 1 To 4
vetB(coluna) = 10
For linha = 1 To 4
If matriz(linha, coluna) < vetB(coluna) Then
vetB(coluna) = matriz(linha, coluna)
End If
Next linha
Next coluna

For linha = 1 To 4
Picture2.Print vetA(linha); Chr(13)
Picture3.Print vetB(linha);
Next linha

cmd1.Enabled = False
cmd2.Enabled = True

End Sub

Private Sub cmd2_Click()

Picture1.Cls
Picture2.Cls
Picture3.Cls
cmd1.Enabled = True
cmd2.Enabled = False

End Sub

Private Sub cmd3_Click()

Beep
End

End Sub

domingo, 13 de dezembro de 2009

Ficha 17-3



Private Sub cmd1_Click()

Dim matriz(1 To 5, 1 To 3), aluno As Integer, nota As Integer, cont As Integer
Dim maior As Integer, positiva As Integer, negativa As Integer, superior As Integer

cont = 0
positiva = 0
negativa = 0
superior = 0

For aluno = 1 To 5
For nota = 1 To 3
matriz(aluno, nota) = Val(InputBox("Introduza a " & nota & "º nota e " & aluno & "º aluno", "Notas"))
Picture1.Print matriz(aluno, nota);
cont = cont + 1
If cont = 3 Then
Picture1.Print Chr(13)
cont = 0
End If
If nota = 1 Then
If matriz(aluno, nota) < 10 Then
negativa = negativa + 1
End If
End If
If nota = 2 Then
If matriz(aluno, nota) > 9 Then
positiva = positiva + 1
End If
End If
If nota = 3 Then
If matriz(aluno, nota) > 16 Then
superior = superior + 1
End If
End If
Next nota
Next aluno

Picture2.Print "Alunos com nota negativa na 1ª prova -> " & negativa
Picture2.Print "Alunos com positiva na 2ª prova -> " & positiva
Picture2.Print "Alunos com nota superior a 16 na 3ª prova -> " & superior

cmd1.Enabled = False
cmd2.Enabled = True

End Sub


Private Sub cmd2_Click()

Picture1.Cls
Picture2.Cls
cmd1.Enabled = True
cmd2.Enabled = False

End Sub

Private Sub cmd3_Click()
End
End Sub

Ficha 17-2





Private Sub cmd1_Click()

Dim matriz(1 To 3, 1 To 5), linha As Integer, coluna As Integer, cont As Integer
Dim maior As Integer, par As Integer, impar As Integer, zero As Integer

cont = 0

For linha = 1 To 3
For coluna = 1 To 5
matriz(linha, coluna) = Val(InputBox("Introduza o número da " & linha & "º linha e " & coluna & "º coluna", "Inserir Valores"))
If matriz(linha, coluna) <= 25 And matriz(linha, coluna) >= 0 Then
Picture1.Print matriz(linha, coluna);
cont = cont + 1
If cont = 5 Then
Picture1.Print Chr(13)
cont = 0
End If
If matriz(linha, coluna) = 0 Then
zero = zero + 1
End If
If matriz(linha, coluna) Mod 2 = 0 Then
par = par + 1
If matriz(linha, coluna) = 0 Then
par = par - 1
End If
End If
If matriz(linha, coluna) Mod 2 = 1 Then
impar = impar + 1
End If
Else
If matriz(linha, coluna) < 0 Then
MsgBox "O número que introduziu era inferior a 0", vbOKOnly + vbInformation, "Inserir Valores"
linha = 3
coluna = 5
Picture1.Cls
zero = 0
par = 0
impar = 0
ElseIf matriz(linha, coluna) > 25 Then
MsgBox "O número que introduziu era superior a 25", vbOKOnly + vbInformation, "Inserir Valores"
linha = 3
coluna = 5
Picture1.Cls
zero = 0
par = 0
impar = 0
End If
End If
Next coluna
Next linha

cmd1.Enabled = False
cmd2.Enabled = True

Picture2.Print "Número de ''0'' introduzidos -> " & zero
Picture2.Print "Números pares introduzidos -> " & par
Picture2.Print "Números impares introduzidos -> " & impar

If zero = 0 And par = 0 And impar = 0 Then
Picture1.Cls
Picture2.Cls
cmd1.Enabled = True
cmd2.Enabled = False
End If

End Sub

Private Sub cmd2_Click()

Picture1.Cls
Picture2.Cls
cmd1.Enabled = True
cmd2.Enabled = False

End Sub

Private Sub cmd3_Click()
End
End Sub

Ficha 17-1



Private Sub cmd1_Click()

Dim matriz(1 To 6, 1 To 6), linha As Integer, coluna As Integer, cont As Integer
Dim maior As Integer, Plinha As Integer, Pcoluna As Integer

cont = 0

Randomize

' Preenchimento da matriz com números aleatórios

For linha = 1 To 6
For coluna = 1 To 6
matriz(linha, coluna) = Int(Rnd() * 49) + 1
Picture1.Print matriz(linha, coluna);
cont = cont + 1
If cont = 6 Then
Picture1.Print Chr(13)
cont = 0
End If
Next coluna
Next linha

' Inicialização do maior e das respectiva posição

maior = matriz(1, 1)
Plinha = 1
Pcoluna = 1

' Pesquisa do maior elemento da matriz e da posição que nela ocupa
For linha = 1 To 6
For coluna = 1 To 6
If matriz(linha, coluna) > maior Then
maior = matriz(linha, coluna)
Plinha = linha
Pcoluna = coluna
End If
Next coluna
Next linha

Label1.Caption = maior
Picture2.Print Tab(4); "Linha " & Plinha & " e coluna " & Pcoluna

cmd1.Enabled = False

End Sub

Private Sub cmd2_Click()

Picture1.Cls
Picture2.Cls
Label1.Caption = ""
cmd1.Enabled = True

End Sub

Private Sub cmd3_Click()
End
End Sub

Relatório - Visita de Estudo




Dia 9 de Dezembro de 2009.
Pelas 8:00 estava eu a chegar ao portão da escola Amato Lusitano (a minha escola).
Há espera do autocarro estava eu e os meus amigos na galhofa. Quando ele chegou ai estava-mos nos de partida para Lisboa, e eu lá ao fundo do autocarro a curtir o som mais o Rafa.
No meio de muita música e PSP pará-mos nós numa estação de serviço perto de Santarém para esticar um pouco as pernas..
Depois de andar pela estação de serviço a fazer muita coisa seguimos de novo rumo a Lisboa.
Ao entrar em Lisboa deixe-me dormir, só acordei quando infelizmente passa-mos pelo estádio do Sporting.
Ao chegar-mos perto do Museu das Comunicações alimentei-me um pouco. Quando chega-mos a porta, por volta das 11:38 tive-mos que esperar porque a visita só poderia começar ás 12:00.
Uns foram á casa do Futuro e outros á Future Labs. No Future Labs vimos o melhor das mais altas tecnologias, o que mais gostei foi daquele plasma onde me imaginava a jogar PES2010 !
Depois da visita ao Labs esperamos pelos que foram á casa do Futuro, mas antes disso tive um contra tempo na casa de banho.
De partida a pé para o Mc Donald's, ao lá chegar pedi o bem dito da bucha ! Um Menu médio Mc Chicken seguido com Coca-Cola, batatas e uma Sanduíche Deluxe.
Depois de ter tudo isso no estômago tive de novo um contratempo na casa de banho.
Depois da casa de banho fomos dar uma voltinha a volta do Mc Donald's para de seguida irmos para o autocarro rumo ao Monte da Caparica para o YDreams.
Ao chegar lá tive-mos de esperar cerca de uma hora para poder lá ir fazer a visita.
Quando chegou a hora fizemos a visita dentro do estabelecimento ao qual vi-mos muitas coisas que não me lembro dos nomes, mas tenho algumas fotos.
Depois de muita coisa vista e conversada, ai fomos nós de novo para o autocarro.
Rumo ao Vasco da Gama, onde visita-mos muitas lojas e onde alguns fizeram comprar lá.
7:15, estava eu e o meu grupo já a espera de poder entrar para o autocarro, pois já era hora de partir para Castelo Branco City..
Durante o caminho vi-mos um filme, ouvi-mos musica e desta vez não me deixei dormir..
Pouco antes de chegar ás 10:00 da noite estava-mos nós a chegar ao portão da escola, e ai onde eu e o Bruno espera-mos pelo pai dele para a gente ir embora.
E assim foi a minha visita de estudo !

domingo, 6 de dezembro de 2009

Ficha 16-2





Private Sub cmdadd_Click()

If txtitem = "" Then
txtitem = MsgBox("Introduza algum número !", vbOKOnly + vbExclamation, "Form1")
txtitem = ""
Else
lstlista.AddItem txtitem
End If

End Sub

Private Sub cmdlimpa_Click()

If txtitem = "" Then
txtitem = MsgBox("A caixa de texto está vazia .", vbOKOnly + vbInformation, "Form1")
txtitem = ""
Else
txtitem = ""
End If

End Sub

Private Sub cmdremove_Click()

Dim n As Integer

n = lstlista.ListCount

If n = 0 Then
n = MsgBox("Não tem números para apagar .", vbOKOnly + vbInformation, "Form1")
Else
lstlista.RemoveItem n - 1
End If

End Sub

Ficha 16-1





Private Sub Command1_Click()

Dim total As Single

If gramas = "" Then
MsgBox "Introduza as gramas!", vbOKOnly + vbExclamation, "Campo obrigatório"

ElseIf Combo1.Text = "Destino:" Then
MsgBox "Escolha o Destino!", vbOKOnly + vbExclamation, "Campo obrigatório"

ElseIf Combo1.Text = "América do Sul" Then
total = gramas * 43 / 200
endereco = "Brasil, Argentina"

ElseIf Combo1.Text = "América do Norte" Then
total = gramas * 48 / 200
endereco = "EUA, Canada"

ElseIf Combo1.Text = "Europa" Then
total = gramas * 50 / 200
endereco = "França, Itália"

ElseIf Combo1.Text = "África" Then
total = gramas * 47 / 200
endereco = "Angola, Marrocos"

ElseIf Combo1.Text = "Ásia" Then
total = gramas * 52 / 200
endereco = "China, Índia"

ElseIf Combo1.Text = "Resto do Mundo" Then
total = gramas * 51 / 200
endereco = "Planeta"

End If

If total = 0 Then
preco.Caption = ""
Else
preco.Caption = total & " €"
End If

End Sub

Private Sub Command2_Click()

End

End Sub

Private Sub Form_Load()

Combo1.AddItem "América do Sul"
Combo1.AddItem "América do Norte"
Combo1.AddItem "Europa"
Combo1.AddItem "África"
Combo1.AddItem "Ásia"
Combo1.AddItem "Resto do Mundo"

End Sub

Ficha 15-3



Private Sub cmd1_Click()

Dim n(1 To 5) As Single, i As Integer, aumento As Single

For i = 1 To 5
n(i) = Val(InputBox("Introduza o preço do " & i & "º artigo", "Artigos"))
If n(i) = 0 Then
n(i) = MsgBox("Introduza um valor de um artigo que não seja ''0''", vbOKOnly + vbInformation, "Artigos")
i = 5
Picture1.Cls
Picture2.Cls
cmd1.Enabled = True
Else
Picture1.Print "Preço normal -> " & n(i) & " €"
aumento = n(i) + (n(i) * 5 / 100)
Picture2.Print "Preço com aumento de 5% -> " & aumento & " €"
cmd1.Enabled = False
End If

Next i

End Sub

Private Sub cmd2_Click()
End
End Sub


Private Sub cmd3_Click()
Picture1.Cls
Picture2.Cls
cmd1.Enabled = True
End Sub

Ficha 15-2





Private Sub cmd1_Click()

Dim temp(1 To 6) As Integer, soma As Integer, cont As Integer, tempmaior As Integer, tempmenor As Integer, media As Single
Dim i As Integer, contp As Integer

media = 0
tempmaior = 0
tempmenor = 100
soma = 0
cont = 0
contp = 4

For i = 1 To 6
If contp < 12 Then
ampm = "manha"
ElseIf contp < 18 Then
ampm = "tarde"
ElseIf contp > 19 Then
ampm = "noite"
End If
temp(i) = Val(InputBox("Introduza a temperatura às " & contp & " horas da " & ampm, "Temperatura"))
registotemp.Print "Temperatura registada às " & contp & " horas da " & ampm & " -> "; temp(i) & " ºC"
contp = contp + 4
soma = soma + temp(i)
If temp(i) > -20 Then
cont = cont + 1
If temp(i) > tempmaior Then
tempmaior = temp(i)
End If
If temp(i) < tempmenor Then
tempmenor = temp(i)
End If
End If
Next i

cmd1.Enabled = False
cmd2.Enabled = True

ampli = tempmaior - tempmenor
media = Round(soma / cont, 1)

max.Caption = tempmaior & " ºC"
min.Caption = tempmenor & " ºC"

amplitude.Print "A amplitude térmica registada foi " & ampli & " ºC"

If media >= 15 Then
Image1.Visible = True
Image2.Visible = False
Image3.Visible = False
Image4.Visible = False
ElseIf media < 15 And media > 8 Then
Image1.Visible = False
Image2.Visible = True
Image3.Visible = False
Image4.Visible = False
ElseIf media <= 8 And media > 3 Then
Image1.Visible = False
Image2.Visible = False
Image3.Visible = True
Image4.Visible = False
ElseIf media <= 3 Then
Image1.Visible = False
Image2.Visible = False
Image3.Visible = False
Image4.Visible = True
End If

End Sub

Private Sub cmd2_Click()
End
End Sub

Private Sub Timer1_Timer()
Hora = Time
Data = Date
End Sub

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

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