Codigo Fuente

You might also like

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 5

INSTITUTO TECNOLOGICO DE DELICIAS

MATERIA: ADMINISTRACIÓN DE ARCHIVOS


Dim re As String * 30
Dim res As String * 8
Dim na2 As Integer
Dim X As Integer
Dim na As Integer
Dim resp As String * 40
Dim n As Integer
Dim num As Integer
Dim reg As Registro

Private Sub Command1_Click()


num = FreeFile
n = Len(reg)
Open "c:\Registro.txt" For Random As num Len = n
na2 = LOF(1) / n
Do While na2 > 0
Get #1, na2, reg
na2 = na2 - 1
If Text6.Text = reg.nc Then
MsgBox "El número de control ya existe"
X=1
End If
Loop
If X = 0 Then
na = LOF(1) / n
na2 = na + 1
reg.nc = Text6.Text
reg.nombre = Text1.Text
reg.direccion = Text2.Text
reg.edad = Val(Text3.Text)
reg.carrera = Text4.Text
reg.semestre = Val(Text5.Text)
Put #1, na2, reg
Text7.Text = na2
MsgBox "ALUMNO REGISTRADO"
Close
Command4.SetFocus
Else
Text6.SetFocus
End If
End Sub

Private Sub Command2_Click()


X=0
resp = InputBox("Escribe el nombre a buscar", "Buscar por Nombre", "")
num = FreeFile
n = Len(reg)
Open "c:\Registro.txt" For Random As num Len = n
na2 = LOF(1) / n
Do While na2 > 0
Get #1, na2, reg
If resp = reg.nombre Then
Text6.Text = reg.nc
Text1.Text = reg.nombre
Text2.Text = reg.direccion
Text3.Text = Val(reg.edad)
Text4.Text = reg.carrera
Text5.Text = Val(reg.semestre)
X=1
Text7.Text = na2
End If
na2 = na2 - 1
Loop
1
INSTITUTO TECNOLOGICO DE DELICIAS
MATERIA: ADMINISTRACIÓN DE ARCHIVOS
Close
If X = 0 Then
MsgBox "Nombre no encontrado"
End If
End Sub

Private Sub Command3_Click()


If MsgBox("Seguro que quiere salir del programa", vbQuestion + vbYesNo + vbDefaultButton1, "Salir") = 6 Then
MsgBox "PROGRAMAM ELABORADO POR:" & vbCrLf & "LUIS ALFONSO POZAS VALENZUELA", , "ADMINISTRACIÓN DE
ARCHIVOS"
End
End If
End Sub

Private Sub Command4_Click()


Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text6.SetFocus
End Sub

Private Sub Command5_Click()


num = FreeFile
n = Len(reg)
Open "c:\Registro.txt" For Random As num Len = n
Get #1, Text7.Text, reg
Text6.Text = reg.nc
Text1.Text = reg.nombre
Text2.Text = reg.direccion
Text3.Text = Val(reg.edad)
Text4.Text = reg.carrera
Text5.Text = Val(reg.semestre)
Close
End Sub

Private Sub Command6_Click()


num = FreeFile
n = Len(reg)
Open "c:\Registro.txt" For Random As num Len = n
na = LOF(1) / n
If Text7.Text < na Then
Text7.Text = Text7.Text + 1
Get #1, Text7.Text, reg
Text6.Text = reg.nc
Text1.Text = reg.nombre
Text2.Text = reg.direccion
Text3.Text = Val(reg.edad)
Text4.Text = reg.carrera
Text5.Text = Val(reg.semestre)
End If
Close
End Sub

Private Sub Command7_Click()


If Text7.Text > 1 Then
Text7.Text = Text7.Text - 1
num = FreeFile
n = Len(reg)
Open "c:\Registro.txt" For Random As num Len = n
Get #1, Text7.Text, reg
2
INSTITUTO TECNOLOGICO DE DELICIAS
MATERIA: ADMINISTRACIÓN DE ARCHIVOS
Text6.Text = reg.nc
Text1.Text = reg.nombre
Text2.Text = reg.direccion
Text3.Text = Val(reg.edad)
Text4.Text = reg.carrera
Text5.Text = Val(reg.semestre)
End If
Close
End Sub

Private Sub Form_Activate()


num = FreeFile
n = Len(reg)
Open "c:\Registro.txt" For Random As num Len = n
Text7.Text = LOF(1) / n
Text6.SetFocus
End Sub

Private Sub mnuAGuardar_Click()


num = FreeFile
n = Len(reg)
Open "c:\Registro.txt" For Random As num Len = n
na2 = LOF(1) / n
Do While na2 > 0
Get #1, na2, reg
na2 = na2 - 1
If Text6.Text = reg.nc Then
MsgBox "El número de control ya existe"
X=1
End If
Loop
If X = 0 Then
na = LOF(1) / n
na2 = na + 1
reg.nc = Text6.Text
reg.nombre = Text1.Text
reg.direccion = Text2.Text
reg.edad = Val(Text3.Text)
reg.carrera = Text4.Text
reg.semestre = Val(Text5.Text)
Put #1, na2, reg
Close
Text7.Text = na2
Command4.SetFocus
Else
Text6.SetFocus
End If
End Sub

Private Sub mnuANuevo_Click()


Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text6.SetFocus
End Sub

Private Sub mnuASalir_Click()


End
End Sub

3
INSTITUTO TECNOLOGICO DE DELICIAS
MATERIA: ADMINISTRACIÓN DE ARCHIVOS
Private Sub mnuBcon_Click()
X=0
res = InputBox("Escribe el No. de Control a buscar", "Buscar por No. de Control", "")
num = FreeFile
n = Len(reg)
Open "c:\Registro.txt" For Random As num Len = n
na2 = LOF(1) / n
Do While na2 > 0
Get #1, na2, reg
If res = reg.nc Then
Text6.Text = reg.nc
Text1.Text = reg.nombre
Text2.Text = reg.direccion
Text3.Text = Val(reg.edad)
Text4.Text = reg.carrera
Text5.Text = Val(reg.semestre)
Text7.Text = na2
X=1
End If
na2 = na2 - 1
Loop
Close
If X = 0 Then
MsgBox "Número no encontrado"
End If
End Sub

Private Sub mnuBDir_Click()


X=0
re = InputBox("Escribe la Dirección a buscar", "Buscar por Direccion", "")
num = FreeFile
n = Len(reg)
Open "c:\Registro.txt" For Random As num Len = n
na2 = LOF(1) / n
Do While na2 > 0
Get #1, na2, reg
If re = reg.direccion Then
Text6.Text = reg.nc
Text1.Text = reg.nombre
Text2.Text = reg.direccion
Text3.Text = Val(reg.edad)
Text4.Text = reg.carrera
Text5.Text = Val(reg.semestre)
Text7.Text = na2
X=1
End If
na2 = na2 - 1
Loop
Close
If X = 0 Then
MsgBox "Dirección no encontrada"
End If
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)


If KeyAscii = 13 Then
Text2.SetFocus
End If
End Sub

Private Sub Text2_KeyPress(KeyAscii As Integer)


If KeyAscii = 13 Then
Text3.SetFocus
4
INSTITUTO TECNOLOGICO DE DELICIAS
MATERIA: ADMINISTRACIÓN DE ARCHIVOS
End If
End Sub

Private Sub Text3_KeyPress(KeyAscii As Integer)


If KeyAscii = 13 Then
Text4.SetFocus
End If
End Sub

Private Sub Text4_KeyPress(KeyAscii As Integer)


If KeyAscii = 13 Then
Text5.SetFocus
End If
End Sub

Private Sub Text5_KeyPress(KeyAscii As Integer)


If KeyAscii = 13 Then
Command1.SetFocus
End If
End Sub

Private Sub Text6_KeyPress(KeyAscii As Integer)


If KeyAscii = 13 Then
Text1.SetFocus
End If
End Sub

You might also like