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

Sem comentários:

Enviar um comentário