quarta-feira, 17 de fevereiro de 2010

Ficha 22 - Em base de Dados







Private Sub Sair_Click()

If MsgBox("Deseja sair?", vbYesNo + vbQuestion, " Aviso") = vbYes Then End

End Sub

Private Sub cmdPrimeiro_Click()
If Data1.Recordset.BOF Then
MsgBox " Base de dados vazia"
Else
Data1.Recordset.MoveFirst
End If

End Sub
Private Sub cmdSeguinte_Click()

If Data1.Recordset.EOF Then
If Data1.Recordset.BOF Then
MsgBox "Base de Dados vazia!"
End If
Else
Data1.Recordset.MoveNext
If Data1.Recordset.EOF Then
Data1.Recordset.MoveLast
End If
End If

End Sub
Private Sub cmdAnterior_Click()

If Data1.Recordset.BOF Then
If Data1.Recordset.EOF Then
MsgBox "Base de Dados vazia!"
End If
Else
Data1.Recordset.MovePrevious
If Data1.Recordset.BOF Then
Data1.Recordset.MoveFirst
End If
End If

End Sub
Private Sub cmdUltimo_Click()
If Data1.Recordset.EOF Then
MsgBox " Base de dados vazia"
Else
Data1.Recordset.MoveLast
End If

End Sub

Private Sub Form_Load()

cmdGuardar.Enabled = False

End Sub
Private Sub cmdAdicionar_Click()

If cmdAdicionar.Caption = "Adicionar" Then
Data1.Recordset.AddNew
txtcodigo.SetFocus
txtfuncionario.SetFocus
txtsalario.SetFocus
txtvale.SetFocus


cmdEliminar.Enabled = False
cmdGuardar.Enabled = True
cmdAdicionar.Caption = "Cancelar"
Else

cmdEliminar.Enabled = True
cmdGuardar.Enabled = False
cmdAdicionar.Caption = "Adicionar"
End If

End Sub
Private Sub cmdGuardar_Click()

Dim Resp As Integer, Mens As String

If txtcodigo.Text = Empty Then

MsgBox "Preencha o campo Código", vbOKOnly + vbExclamation, " Aviso"

ElseIf txtfuncionario.Text = Empty Then

MsgBox "Preencha o campo Funcionário", vbOKOnly + vbExclamation, " Aviso"

ElseIf txtsalario.Text = Empty Then

MsgBox "Preencha o campo Salário", vbOKOnly + vbExclamation, " Aviso"

ElseIf txtvale.Text = Empty Then

MsgBox "Preencha o campo Vale", vbOKOnly + vbExclamation, " Aviso"

Else
Mens = "Deseja guardar os novos dados?"
Resp = MsgBox(Mens, vbYesNo + vbQuestion, "Question")

If Resp = vbYes Then
txttotal.Text = Val(txtsalario.Text) + Val(txtvale.Text)

Data1.Recordset.Update
cmdEliminar.Enabled = True
cmdGuardar.Enabled = False
cmdAdicionar.Caption = "Adicionar"
End If
End If

End Sub
Private Sub cmdEliminar_click()

If MsgBox("Deseja eliminar este registo?", vbYesNo + vbQuestion, "Question") = vbNo Then
MsgBox "Registo não eliminado"
Else
Data1.Recordset.Delete
Data1.Recordset.MoveNext

If Data1.Recordset.EOF Then
Data1.Recordset.MovePrevious

If Data1.Recordset.BOF Then
MsgBox "Não há registos"
cmdEliminar.Enabled = False
End If

End If
MsgBox "Registo Eliminado"
End If

End Sub

Private Sub Retroceder_Click()

End Sub

Private Sub Timer1_Timer()

Hora_Data = Now

End Sub

Private Sub txtcodigo_KeyPress(KeyAscii As Integer)
If Not IsNumeric(Chr(KeyAscii)) And KeyAscii <> 8 Then
KeyAscii = 0
End If
End Sub

Private Sub txtfuncionario_KeyPress(KeyAscii As Integer)

Select Case KeyAscii
Case vbKeyDelete
Case vbKeyBack
Case 65 To 90
Case 97 To 122
Case 32
Case Else
Beep
KeyAscii = 0
End Select

End Sub

Private Sub txtsalario_KeyPress(KeyAscii As Integer)
If Not IsNumeric(Chr(KeyAscii)) And KeyAscii <> 8 Then
KeyAscii = 0
End If
End Sub

Private Sub txtvale_KeyPress(KeyAscii As Integer)
If Not IsNumeric(Chr(KeyAscii)) And KeyAscii <> 8 Then
KeyAscii = 0
End If
End Sub

domingo, 7 de fevereiro de 2010

Ficha 23





Private Type Folha

matricula As Long
nome As String * 40
nota1 As Long
nota2 As Long
media As Single

End Type

Dim tabela(19) As Folha

Dim i As Integer, j As Integer

Private Sub Avancar2_Click()

mensagem.Enabled = False
Limpar.Enabled = True
retroceder.Enabled = True
Retroceder2.Enabled = True

If j < i - 1 Then

j = j + 1

ver_dados (j)

End If

If j = i - 1 Then

avancar.Enabled = False
Avancar2.Enabled = False

End If

End Sub

Private Sub retroceder_Click()

mensagem.Enabled = False
Limpar.Enabled = True
avancar.Enabled = True
Avancar2.Enabled = True

If j > 0 Then

j = j - 1

ver_dados (j)

End If

If j = 0 Then

retroceder.Enabled = False
Retroceder2.Enabled = False

End If

End Sub

Private Sub avancar_Click()

mensagem.Enabled = False
Limpar.Enabled = True
retroceder.Enabled = True
Retroceder2.Enabled = True


If j < i - 1 Then

j = j + 1

ver_dados (j)

End If

If j = i - 1 Then

avancar.Enabled = False
Avancar2.Enabled = False

End If

End Sub

Private Sub Form_Load()

i = 0

End Sub

Private Sub mensagem_Click()



If txtmatricula.Text = Empty Then

MsgBox "Preencha o campo Matrícula", vbOKOnly + vbExclamation, " Aviso"

ElseIf txtnome.Text = Empty Then

MsgBox "Preencha o campo Nome", vbOKOnly + vbExclamation, " Aviso"

ElseIf txtnota1.Text = Empty Then

MsgBox "Preencha o campo Nota 1", vbOKOnly + vbExclamation, " Aviso"

ElseIf txtnota2.Text = Empty Then

MsgBox "Preencha o campo Nota 2", vbOKOnly + vbExclamation, " Aviso"

ElseIf txtnota1.Text < 0 Or txtnota1.Text > 20 Then

MsgBox "Nota 1 excedida", vbOKOnly + vbCritical, " Aviso"

ElseIf txtnota2.Text < 0 Or txtnota2.Text > 20 Then

MsgBox "Nota 2 excedida", vbOKOnly + vbCritical, " Aviso"

Else

tabela(i).matricula = txtmatricula.Text
tabela(i).nome = txtnome.Text
tabela(i).nota1 = txtnota1.Text
tabela(i).nota2 = txtnota2.Text

MsgBox "Dados Inseridos", vbOKOnly + vbInformation, " Mensagem"

txtmedia.Text = (Val(txtnota1.Text) + Val(txtnota2.Text)) / 2
tabela(i).media = (Val(txtnota1.Text) + Val(txtnota2.Text)) / 2

i = i + 1
j = i

mensagem.Enabled = False
retroceder.Enabled = False
Retroceder2.Enabled = False
avancar.Enabled = False
Avancar2.Enabled = False
Limpar.Enabled = True

End If

End Sub

Private Sub Limpar_Click()

txtmatricula.Text = ""
txtnome.Text = ""
txtnota1.Text = ""
txtnota2.Text = ""
txtmedia.Text = ""

mensagem.Enabled = True
retroceder.Enabled = True
Retroceder2.Enabled = True
avancar.Enabled = True
Avancar2.Enabled = True
Limpar.Enabled = False

End Sub

Private Sub Retroceder2_Click()

mensagem.Enabled = False
Limpar.Enabled = True
avancar.Enabled = True
Avancar2.Enabled = True

If j > 0 Then

j = j - 1

ver_dados (j)

End If

If j = 0 Then

retroceder.Enabled = False
Retroceder2.Enabled = False

End If

End Sub

Private Sub Sair_Click()

If MsgBox("Deseja sair?", vbYesNo + vbQuestion, " Aviso") = vbYes Then End

End Sub

Private Sub Timer1_Timer()

Hora_Data = Now

End Sub
Private Sub ver_dados(k As Integer)

txtmatricula.Text = tabela(k).matricula
txtnome.Text = tabela(k).nome
txtnota1.Text = tabela(k).nota1
txtnota2.Text = tabela(k).nota2
txtmedia.Text = tabela(k).media

End Sub

Private Sub txtmatricula_KeyPress(KeyAscii As Integer)
If Not IsNumeric(Chr(KeyAscii)) And KeyAscii <> 8 Then
KeyAscii = 0
End If
End Sub

Private Sub txtnome_KeyPress(KeyAscii As Integer)

Select Case KeyAscii
Case vbKeyDelete
Case vbKeyBack
Case 65 To 90
Case 97 To 122
Case 128 To 154
Case 159 To 165
Case 32
Case Else
Beep
KeyAscii = 0
End Select

End Sub

Private Sub txtnota1_KeyPress(KeyAscii As Integer)
If Not IsNumeric(Chr(KeyAscii)) And KeyAscii <> 8 Then
KeyAscii = 0
End If
End Sub

Private Sub txtnota2_KeyPress(KeyAscii As Integer)
If Not IsNumeric(Chr(KeyAscii)) And KeyAscii <> 8 Then
KeyAscii = 0
End If
End Sub

quinta-feira, 4 de fevereiro de 2010

Ficha 22







~Private Type Folha

codigo As Long
funcionario As String * 40
salario As Long
vale As Long
total As Long

End Type

Dim tabela(11) As Folha

Dim i As Integer, j As Integer

Private Sub Avancar2_Click()

Incluir.Enabled = False
Limpar.Enabled = True
Retroceder.Enabled = True
Retroceder2.Enabled = True

If j < i - 1 Then

j = j + 1

ver_dados (j)

End If

If j = i - 1 Then

Avancar.Enabled = False
Avancar2.Enabled = False

End If

End Sub

Private Sub retroceder_Click()

Incluir.Enabled = False
Limpar.Enabled = True
Avancar.Enabled = True
Avancar2.Enabled = True

If j > 0 Then

j = j - 1

ver_dados (j)

End If

If j = 0 Then

Retroceder.Enabled = False
Retroceder2.Enabled = False

End If

End Sub

Private Sub avancar_Click()

Incluir.Enabled = False
Limpar.Enabled = True
Retroceder.Enabled = True
Retroceder2.Enabled = True


If j < i - 1 Then

j = j + 1

ver_dados (j)

End If

If j = i - 1 Then

Avancar.Enabled = False
Avancar2.Enabled = False

End If

End Sub

Private Sub Form_Load()

i = 0

End Sub

Private Sub Incluir_Click()


If txtcodigo.Text = Empty Then

MsgBox "Preencha o campo Código", vbOKOnly + vbExclamation, " Aviso"

ElseIf txtfuncionario.Text = Empty Then

MsgBox "Preencha o campo Funcionário", vbOKOnly + vbExclamation, " Aviso"

ElseIf txtsalario.Text = Empty Then

MsgBox "Preencha o campo Salário", vbOKOnly + vbExclamation, " Aviso"

ElseIf txtvale.Text = Empty Then

MsgBox "Preencha o campo Vale", vbOKOnly + vbExclamation, " Aviso"

Else

tabela(i).codigo = txtcodigo.Text
tabela(i).funcionario = txtfuncionario.Text
tabela(i).salario = txtsalario.Text
tabela(i).vale = txtvale.Text

MsgBox "Dados Inseridos", vbOKOnly + vbInformation, " Mensagem"

txttotal.Text = Val(txtsalario) + Val(txtvale.Text)
tabela(i).total = Val(txtsalario) + Val(txtvale.Text)

i = i + 1
j = i

Incluir.Enabled = False
Retroceder.Enabled = False
Retroceder2.Enabled = False
Avancar.Enabled = False
Avancar2.Enabled = False
Limpar.Enabled = True

End If

End Sub

Private Sub Limpar_Click()

txtcodigo.Text = ""
txtfuncionario.Text = ""
txtsalario.Text = ""
txtvale.Text = ""
txttotal.Text = ""

Incluir.Enabled = True
Retroceder.Enabled = True
Retroceder2.Enabled = True
Avancar.Enabled = True
Avancar2.Enabled = True
Limpar.Enabled = False

End Sub

Private Sub Retroceder2_Click()

Incluir.Enabled = False
Limpar.Enabled = True
Avancar.Enabled = True
Avancar2.Enabled = True

If j > 0 Then

j = j - 1

ver_dados (j)

End If

If j = 0 Then

Retroceder.Enabled = False
Retroceder2.Enabled = False

End If

End Sub

Private Sub Sair_Click()

If MsgBox("Deseja sair?", vbYesNo + vbQuestion, " Aviso") = vbYes Then End

End Sub

Private Sub Timer1_Timer()

Hora_Data = Now

End Sub
Private Sub ver_dados(k As Integer)

txtcodigo.Text = tabela(k).codigo
txtfuncionario.Text = tabela(k).funcionario
txtsalario.Text = tabela(k).salario
txtvale.Text = tabela(k).vale
txttotal.Text = tabela(k).total

End Sub

Private Sub txtcodigo_KeyPress(KeyAscii As Integer)
If Not IsNumeric(Chr(KeyAscii)) And KeyAscii <> 8 Then
KeyAscii = 0
End If
End Sub

Private Sub txtfuncionario_KeyPress(KeyAscii As Integer)

Select Case KeyAscii
Case vbKeyDelete
Case vbKeyBack
Case 65 To 90
Case 97 To 122
Case 32
Case Else
Beep
KeyAscii = 0
End Select

End Sub

Private Sub txtsalario_KeyPress(KeyAscii As Integer)
If Not IsNumeric(Chr(KeyAscii)) And KeyAscii <> 8 Then
KeyAscii = 0
End If
End Sub

Private Sub txtvale_KeyPress(KeyAscii As Integer)
If Not IsNumeric(Chr(KeyAscii)) And KeyAscii <> 8 Then
KeyAscii = 0
End If
End Sub

sexta-feira, 29 de janeiro de 2010

Ficha 21



Const PI = 3.14

Private Function VCilindro(x As Single, z As Single) As Single
VCilindro = PI * x ^ 2 * z
End Function
Private Function ACirculo(x As Single) As Single
ACirculo = PI * x ^ 2
End Function
Private Function VCubo(x As Single) As Single
VCubo = x ^ 3
End Function
Private Function AEsfera(x As Single) As Single
AEsfera = 4 * PI * x ^ 2
End Function
Private Function VEsfera(x As Single) As Single
VEsfera = 4 / 3 * PI * x ^ 3
End Function
Private Function AQuadrado(x As Single) As Single
AQuadrado = x * x
End Function
Private Function PQuadrado(x As Single) As Single
PQuadrado = x * x * x * x
End Function
Private Function ARectangulo(x As Single, z As Single) As Single
ARectangulo = x * z
End Function
Private Function PRectangulo(x As Single, z As Single) As Single
PRectangulo = 2 * (x + z)
End Function
Private Function ATriangulo(x As Single, z As Single) As Single
ATriangulo = x * z / 2
End Function
Private Function PTriangulo(x As Single) As Single
PTriangulo = x + x + x
End Function

Private Sub Autor_Click()

MsgBox "Programa protagonizado por João Florindo", vbOKOnly, "Exercício - Autor"

End Sub

Private Sub Cilindro_Click()

Dim r As Single, h As Single, v As Single

Do
r = Val(InputBox("Digite o valor do raio", "Volume do Cilindro"))
Loop While r <= 0
Do
h = Val(InputBox("Digite o valor da altura", "Volume do Cilindro"))
Loop While h <= 0

v = VCilindro(r, h)

MsgBox "O volume do cilindro é " & v & "m2", 64, " Volume do Cilindro"


End Sub

Private Sub Circulo_Click()

Dim r As Single, a As Single

Do
r = Val(InputBox("Digite o valor do raio", "Área do Círculo"))
Loop While r <= 0

a = ACirculo(r)

MsgBox "A área do círculo é " & a & "m2", 64, " Área do Círculo"

End Sub

Private Sub Cubo_Click()

Dim v As Single, a As Single

Do
a = Val(InputBox("Digite o valor da aresta", "Volume do Cubo"))
Loop While a <= 0

v = VCubo(a)

MsgBox "O volume do cubo é " & v & "m2", 64, " Volume do Cubo"

End Sub

Private Sub Esfera_Click()

Dim a As Single, r As Single

Do
r = Val(InputBox("Digite o valor da esfera", "Área da Esfera"))
Loop While r <= 0

a = AEsfera(r)

MsgBox "A área da esfera é " & a & "m2", 64, " Área da Esfera"

End Sub

Private Sub Esfera2_Click()

Dim v As Single, r As Single

Do
r = Val(InputBox("Digite o valor da esfera", "Volume da Esfera"))
Loop While r <= 0

v = VEsfera(r)

MsgBox "O volume da esfera é " & v & "m2", 64, " Volume da Esfera"

End Sub

Private Sub Quadrado_click()

Dim a As Single, l As Single

Do
l = Val(InputBox("Digite o valor do lado", "Área do Quadrado"))
Loop While l <= 0

a = AQuadrado(l)

MsgBox "A área do quadrado é " & a & "m2", 64, " Área do Quadrado"

End Sub

Private Sub Quadrado2_Click()

Dim p As Single, l As Single

Do
l = Val(InputBox("Digite o valor dos lados", "Perímetro do Quadrado"))
Loop While l <= 0

p = PQuadrado(l)

MsgBox "O perímetro do quadrado é " & p & "m2", 64, " Perímetro do Quadrado"

End Sub

Private Sub Rectangulo_Click()

Dim a As Single, b As Single, h As Single

Do
b = Val(InputBox("Digite o valor da base", "Área do Rectângulo"))
Loop While b <= 0

Do
h = Val(InputBox("Digite o valor da altura", "Área do Rectângulo"))
Loop While h <= 0

a = ARectangulo(b, h)

MsgBox "A área do rectângulo é " & a & "m2", 64, " Área do Rectângulo"

End Sub

Private Sub Rectangulo2_Click()

Dim p As Single, b As Single, h As Single

Do
b = Val(InputBox("Digite o valor da base", "Perímetro do Rectângulo"))
Loop While b <= 0

Do
h = Val(InputBox("Digite o valor da altura", "Perímetro do Rectângulo"))
Loop While h <= 0

p = PRectangulo(b, h)

MsgBox "O perímetro do rectângulo é " & p & "m2", 64, " Perímetro do Rectângulo"

End Sub

Private Sub Sair_Click()

If MsgBox("Deseja mesmo sair?", vbYesNo + vbQuestion, " Exercício - Confirmação") = vbYes Then End

End Sub

Private Sub Triangulo_Click()

Dim a As Single, b As Single, h As Single

Do
b = Val(InputBox("Digite o valor da base", "Área do Triângulo"))
Loop While b <= 0

Do
h = Val(InputBox("Digite o valor da altura", "Área do Triângulo"))
Loop While h <= 0

a = ATriangulo(b, h)

MsgBox "A área do triângulo é " & a & "m2", 64, " Área do Triângulo"

End Sub

Private Sub Triangulo2_Click()

Dim p As Single, l As Single

Do
l = Val(InputBox("Digite o valor dos lados", "Perímetro do Triângulo"))
Loop While l <= 0

p = PTriangulo(l)

MsgBox "O perímetro do triângulo é " & p & "m2", 64, " Perímetro do Triângulo"

End Sub

quinta-feira, 28 de janeiro de 2010

Trabalho 2







Form1:

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()
Form1.Show
If res = Sair Then
r = FU_Delay(3, True)
Form1.Hide
Form2.Show
End If
End Sub


Form2:

Dim movie As Integer, cont As Integer, total As Single, result As Single, mt As Single
Dim mat As Single
Private Sub Calcular_Click()

If Cliente.Text = "" And Val(Filmes.Text) = 0 Then
'Só poderá continuar o programa se os campos do Número do Cliente e Total de filmes a alugar estiverem preenchidos
x = MsgBox("Preencha os campos 'Número do Cliente' e 'Total de filmes a alugar' ", vbOKOnly + vbExclamation, "Campo Obrigatório")
ElseIf Cliente.Text = "" Then
'Terá que ser preenchido o campo Número Cliente para o programa continuar
x = MsgBox("Preencha o campo 'Número do Cliente' ", vbOKOnly + vbExclamation, "Campo Obrigatório")
ElseIf Val(Filmes.Text) = 0 Then
'Terá que ser preenchido o campo Total de filmes a alugar para o programa continuar
x = MsgBox("Preencha o campo 'Total de filmes a alugar' ", vbOKOnly + vbExclamation, "Campo Obrigatório")
Else

'Cont é onde começa a ser contados os clientes
cont = cont + 1

'movie é o número de filmes
movie = Val(Filmes.Text)

'É feita a multiplicação do preço dos filmes que o cliente deseja comprar
total_sem.Caption = Filmes * 2.5 & " €"

'Preço dos filmes sem desconto
mat = Round(Filmes * 2.5, 2)

'Desconto dos filmes
desconto.Caption = mat * 0.1 & " €"

'Preço dos filmes com desconto
total_com.Caption = mat - (mat * 0.1) & " €"


mt = Round(mat - (mat * 0.1), 2)


result = mt


total = Round(total + result, 2)

Total_clientes.Caption = cont
l1 = cont


Total_recebido.Caption = total & " €"
l2 = total

Limpar.Enabled = True
Imprimir.Enabled = True
Calcular.Enabled = False

End If

End Sub

Private Sub Form_Load()

cont = 0
total = 0

End Sub

Private Sub Imprimir_Click()
'Será imprimido os clientes e o total facturado numa nova form
Form3.Show
Load Form3

End Sub

Private Sub Limpar_Click()
'Neste botão a função Limpar serve para limpar os valores do cliente , o número do cliente e o total de filmes a alugar
Cliente.Text = ""
Filmes.Text = ""
total_sem.Caption = ""
desconto.Caption = ""
total_com.Caption = ""

Calcular.Enabled = True
Limpar.Enabled = False
Imprimir.Enabled = False

End Sub

Private Sub Sair_Click()
'Aqui o programa será terminado
x = MsgBox("Deseja mesmo sair?", vbYesNo + vbQuestion, "Vídeo Clube")

If x = vbYes Then
End
Else

End If

End Sub


Form3:

Private Sub Form_Load()
'Será carregado os totais calculados na form2
Label1.Caption = l1
Label2.Caption = l2 & " €"

End Sub

Private Sub Label5_Click()
'O programa voltará de novo a form2 para novos resultados
Label1.Caption = ""
Label2.Caption = ""

Form3.Hide
Unload Form3
End Sub


Module:

Public l1 As Integer, l2 As Single

Trabalho 1







Form1:


Dim neve1 As Integer, neve2 As Integer, nevetotal1 As Integer, nevetotal2 As Integer
Dim mat(1 To 1, 1 To 2) As Integer, l As Integer, ll As Integer

Private Sub Calcular_Click()

If Nome.Text = "" And Val(CC.Text) = 0 Then
x = MsgBox("Preencha o campo 'Nome' e 'CC' ", vbOKOnly + vbExclamation, "Campo Obrigatório")
ElseIf Nome.Text = "" Then
x = MsgBox("Preencha o campo 'Nome' ", vbOKOnly + vbExclamation, "Campo Obrigatório")
ElseIf Val(CC.Text) = 0 Then
x = MsgBox("Preencha o campo 'CC' ", vbOKOnly + vbExclamation, "Campo Obrigatório")
Else

For l = 1 To 1

Picture1.Print "Nome do Cliente"
Picture1.Print Nome
Picture1.Print "Nº do Cartão de Cidadão"
Picture1.Print CC & Chr(13)

For ll = 1 To 2

neve1 = Val(snow1.Text)
neve2 = Val(snow2.Text)

snowtotal1.Caption = neve1 * 20 & " €"
mat(l, 1) = snowtotal1.Caption
snowtotal2.Caption = neve2 * 30 & " €"
mat(l, 2) = snowtotal2.Caption


Next ll
Next l

nevetotal1 = snowtotal1.Caption
nevetotal2 = snowtotal2.Caption
neveal1 = neveal1 + neve1
neveal2 = neveal2 + neve2
snowal1.Caption = neveal1

snowal2.Caption = neveal2

totalgeral.Caption = nevetotal1 + nevetotal2

totalalugueis.Caption = neveal1 + neveal2

alugueltotal = totalalugueis.Caption

End If

If Nome.Text = "" And Val(CC.Text) = 0 Then
Calcular.Enabled = True
ElseIf Nome.Text = "" Then
Calcular.Enabled = True
ElseIf Val(CC.Text) = 0 Then
Calcular.Enabled = True
Else
Calcular.Enabled = False
Imprimir.Enabled = True
Limpar.Enabled = True
LimparTudo.Enabled = True

End If

End Sub

Private Sub Limpar_Click()

Nome.Text = ""
CC.Text = ""
snow1.Text = ""
snow2.Text = ""
snowtotal1.Caption = ""
snowtotal2.Caption = ""
totalgeral.Caption = ""

Calcular.Enabled = True
Limpar.Enabled = False
Imprimir.Enabled = False

End Sub

Private Sub LimparTudo_Click()

Nome.Text = ""
CC.Text = ""
snow1.Text = ""
snow2.Text = ""
snowtotal1.Caption = ""
snowtotal2.Caption = ""
totalgeral.Caption = ""
neveal1 = 0
snowal1.Caption = ""
neveal2 = 0
snowal2.Caption = ""
alugueltotal = 0
totalalugueis.Caption = ""

Calcular.Enabled = True
Limpar.Enabled = False
LimparTudo.Enabled = False
Imprimir.Enabled = False

End Sub

Private Sub Imprimir_Click()

Calcular.Enabled = False
Limpar.Enabled = False
LimparTudo.Enabled = False
Imprimir.Enabled = False
Form2.Show

End Sub

Private Sub Sair_Click()

Picture1.Visible = False
Picture2.Visible = True
MsgBox "Obrigado pela sua visita!", vbOKOnly + vbInformation, "BOA QUEDA - Sair"

End

End Sub

Private Sub Timer1_Timer()

Label1.Caption = Time

End Sub

Form2:

Private Sub Form_Load()

Label1.Caption = neveal1
Label2.Caption = neveal2
Label3.Caption = alugueltotal

End Sub
Private Sub Label5_Click()

Form2.Hide

End Sub


Module:


Public neveal1 As Integer, neveal2 As Integer, alugueltotal As Integer

domingo, 24 de janeiro de 2010

Ficha 20



Private Sub Alegre_Click()

S_Alegre.Visible = True
S_Triste.Visible = False
C_Copas.Visible = False
C_Ouros.Visible = False
C_Paus.Visible = False
C_Espadas.Visible = False

End Sub

Private Sub Copas_Click()

S_Alegre.Visible = False
S_Triste.Visible = False
C_Copas.Visible = True
C_Ouros.Visible = False
C_Paus.Visible = False
C_Espadas.Visible = False

End Sub

Private Sub Espadas_Click()

S_Alegre.Visible = False
S_Triste.Visible = False
C_Copas.Visible = False
C_Ouros.Visible = False
C_Paus.Visible = False
C_Espadas.Visible = True

End Sub


Private Sub Limpar_Click()

S_Alegre.Visible = False
S_Triste.Visible = False
C_Copas.Visible = False
C_Ouros.Visible = False
C_Paus.Visible = False
C_Espadas.Visible = False

End Sub

Private Sub Ouros_Click()

S_Alegre.Visible = False
S_Triste.Visible = False
C_Copas.Visible = False
C_Ouros.Visible = True
C_Paus.Visible = False
C_Espadas.Visible = False

End Sub

Private Sub Paus_Click()

S_Alegre.Visible = False
S_Triste.Visible = False
C_Copas.Visible = False
C_Ouros.Visible = False
C_Paus.Visible = True
C_Espadas.Visible = False

End Sub

Private Sub Sair_Click()

End

End Sub

Private Sub Triste_Click()

S_Alegre.Visible = False
S_Triste.Visible = True
C_Copas.Visible = False
C_Ouros.Visible = False
C_Paus.Visible = False
C_Espadas.Visible = False

End Sub

Ficha 19



Private Sub Command1_Click()

If Combo1 = "Classificação de triângulos" Then
Form2.Show
Form1.Hide
ElseIf Combo1 = "Classificação de circunferência" Then
Form3.Show
Form1.Hide
Else
x = MsgBox("Escolha uma Classificação..", vbOKOnly + vbInformation, "Form1")
End If

End Sub

Private Sub Command2_Click()

End

End Sub

Private Sub Form_Load()

Combo1.AddItem "Classificação de triângulos"
Combo1.AddItem "Classificação de circunferência"

End Sub

Private Sub Timer1_Timer()

Label1 = Time

End Sub




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()

Form2.Hide
Form1.Show

End Sub

Private Sub cmd3_Click()

End

End Sub




Private Sub Command1_Click()

Dim pontox As Integer, pontoy As Integer

Picture1.Cls
Label1.Caption = ""

pontox = Val(InputBox("Intoduza coordenada X", "Introdução de dados"))

Picture1.Print Tab(4); "X=" & pontox
pontoy = Val(InputBox("Introduza coordenada Y", "Introdução de dados"))

Picture1.Print Tab(4); "Y=" & pontoy

If (x - a) ^ 2 + (y - b) ^ 2 Then

Label1.Caption = ("O ponto introduzido é interior à circunferência de centro")

ElseIf (x - a) ^ 2 + (y - b) ^ 2 > r ^ 2 Then
Label1.Caption = ("O ponto introduzido é exterior à circuferencia de centro")

ElseIf (x - a) ^ 2 + (y - b) ^ 2 = r ^ 2 Then
Label1.Caption = ("O ponto introduzido é fronteiro à circuferencia de centro")

Else

MsgBox "Pontos inválidos!", vbOKOnly + vbInformation, "Informação"

End If


End Sub

Private Sub Command2_Click()

Form3.Hide
Form1.Show

End Sub

Private Sub Command3_Click()

End

End Sub

quinta-feira, 7 de janeiro de 2010

Ficha 18-2






Dim matriz(1 To 4, 1 To 3)
Private Sub cmd1_Click()

Dim funcionário As Integer, mes As Integer, cont As Integer, contf As Integer

cont = 0
contf = 1
Picture1.Print Tab(16); "Meses"
For funcionario = 1 To 4
Picture1.Print "Funcionário " & contf & Chr(32); Chr(26);
contf = contf + 1
For mes = 1 To 3
matriz(funcionario, mes) = Val(InputBox("Introduza a " & mes & "º venda do " & funcionario & "º funcionário", "Audi"))
Picture1.Print matriz(funcionario, mes);
cont = cont + 1
If cont = 3 Then
Picture1.Print Chr(13)
cont = 0
End If
Next mes
Next funcionario

cmd1.Enabled = False
cmd2.Enabled = True

End Sub

Private Sub cmd2_Click()

Dim consulta As Integer, soma As Integer, mes As Integer

soma = 0

consulta = Val(InputBox("Qual o total de vendas do Funcionário que vai querer consultar ?" & Chr(13) & "Funcionário 1, 2, 3 ou 4?", "Audi"))

If consulta > 0 And consulta < 5 Then
For mes = 1 To 3
soma = soma + matriz(consulta, mes)
Next mes
Else
erro = MsgBox("O número que introduziu ''" & consulta & "'' não corresponde a nenhum Funcionário" & Chr(13) & Chr(13) & "Por favor tente novamente", vbInformation + vbOKOnly, "Informação")
End If

If consulta > 0 And consulta < 5 Then

Picture2.Print "Funcionário consultado " & Chr(26) & Chr(32) & consulta
Picture2.Print Chr(13); soma
cmd1.Enabled = False
cmd2.Enabled = False
cmd3.Enabled = True
Else
Picture2.Print Chr(13); " erro "
cmd1.Enabled = False
cmd2.Enabled = False
cmd3.Enabled = False
End If

End Sub

Private Sub cmd3_Click()

Dim indice As Integer, total As Integer, funcionario As Integer, contf2 As Integer

total = 0
contf2 = 1

indice = Val(InputBox("Qual o mes de vendas que vai querer consultar ?" & Chr(13) & "Mês 1, 2 ou 3?", "Audi"))

Picture3.Print "Mês " & Chr(26) & Chr(32) & indice & Chr(13)
If indice > 0 And indice < 4 Then
For funcionario = 1 To 4
total = 0
total = total + matriz(funcionario, indice)
Picture3.Print "Funcionário " & contf2
contf2 = contf2 + 1
Picture3.Print Tab(5); total & Chr(13)
Next funcionario
Else
erro = MsgBox("O número que introduziu ''" & indice & "'' não corresponde a nenhum Funcionário" & Chr(13) & Chr(13) & "Por favor tente novamente", vbInformation + vbOKOnly, "Informação")
Picture3.Print "erro"
End If

cmd1.Enabled = False
cmd2.Enabled = False
cmd3.Enabled = False

End Sub

Private Sub cmd4_Click()

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

End Sub

Private Sub cmd5_Click()

End

End Sub

Ficha 18-1




Dim matriz(1 To 4, 1 To 3) As Integer

Private Sub Gerar_Click()

Dim linha As Integer, coluna As Integer, cont As Integer

Randomize

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

Somar.Enabled = True
Gerar.Enabled = False
Limpar.Enabled = True

End Sub

Private Sub Somar_Click()
Dim consulta As Integer, soma As Integer, linha As Integer

soma = 0

consulta = Val(InputBox("Qual a coluna que vai querer consultar ?" & Chr(13) & "Coluna 1, Coluna 2 ou Coluna 3?", "Coluna"))

If consulta > 0 And consulta < 4 Then
For linha = 1 To 4
soma = soma + matriz(linha, consulta)
Next linha
Else
erro = MsgBox("O número que introduziu ''" & consulta & "'' não é o correcto" & Chr(13) & Chr(13) & "Por favor tente novamente", vbInformation + vbOKOnly, "Informação")
End If

If consulta > 0 And consulta < 4 Then
Picture2.Print Chr(13); Tab(5); soma
Else
Picture2.Print Chr(13); Tab(5); " erro"
End If

Gerar.Enabled = False
Somar.Enabled = False

End Sub

Private Sub Limpar_Click()

Picture1.Cls
Picture2.Cls
Gerar.Enabled = True
Somar.Enabled = False
Limpar.Enabled = False

End Sub

Private Sub Sair_Click()

End

End Sub

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