
Registros en blanco en fichero binario
Publicado por dickensoft (10 intervenciones) el 07/11/2008 14:28:29
Tengo una estructura creada :
Public Type Datos
codigo As Integer
curso As String
nombre As String
apellido1 As String
apellido2 As String
fechanac As String
sexo As String
telefono As String
End Type
Public alumno As Datos
y una funcion que al principio me cuenta los registros que tengo creados en el fichero...
Private Sub contar_registros()
Dim longitud As Integer
contador_registros = 0
Open "c:alum.dat" For Binary As 1
Seek #1, 1
Do While Not EOF(1)
Get #1, , alumno.codigo
Get #1, , longitud
alumno.curso = Input(longitud, #1)
Get #1, , longitud
alumno.nombre = Input(longitud, #1)
Get #1, , longitud
alumno.apellido1 = Input(longitud, #1)
Get #1, , longitud
alumno.apellido2 = Input(longitud, #1)
Get #1, , longitud
alumno.fechanac = Input(longitud, #1)
Get #1, , longitud
alumno.sexo = Input(longitud, #1)
Get #1, , longitud
alumno.telefono = Input(longitud, #1)
MsgBox "Datos del alumno" & vbCrLf & "--------------------" & vbCrLf & _
"Codigo: " & alumno.codigo & vbCrLf & "Curso: " & alumno.curso & vbCrLf & _
"Nombre: " & alumno.nombre & vbCrLf & "Apellidos: " & alumno.apellido1 & _
" " & alumno.apellido2 & vbCrLf & "Fecha de nacimiento: " & alumno.fechanac _
& vbCrLf & "Sexo: " & alumno.sexo & vbCrLf & "Teléfono: " & alumno.telefono, vbInformation, "Datos Alumno"
contador_registros = contador_registros + 1
Loop
contador_registros = contador_registros - 1
MsgBox "contador_registros " & contador_registros
End Sub
Pues bien, aunque no tenga ningun registro creado, siempre me entra y me cuenta como mínimo 1 (aunque no se haya creado ninguno), y no se cual es el motivo....
Gracias por vuestra ayuda
Public Type Datos
codigo As Integer
curso As String
nombre As String
apellido1 As String
apellido2 As String
fechanac As String
sexo As String
telefono As String
End Type
Public alumno As Datos
y una funcion que al principio me cuenta los registros que tengo creados en el fichero...
Private Sub contar_registros()
Dim longitud As Integer
contador_registros = 0
Open "c:alum.dat" For Binary As 1
Seek #1, 1
Do While Not EOF(1)
Get #1, , alumno.codigo
Get #1, , longitud
alumno.curso = Input(longitud, #1)
Get #1, , longitud
alumno.nombre = Input(longitud, #1)
Get #1, , longitud
alumno.apellido1 = Input(longitud, #1)
Get #1, , longitud
alumno.apellido2 = Input(longitud, #1)
Get #1, , longitud
alumno.fechanac = Input(longitud, #1)
Get #1, , longitud
alumno.sexo = Input(longitud, #1)
Get #1, , longitud
alumno.telefono = Input(longitud, #1)
MsgBox "Datos del alumno" & vbCrLf & "--------------------" & vbCrLf & _
"Codigo: " & alumno.codigo & vbCrLf & "Curso: " & alumno.curso & vbCrLf & _
"Nombre: " & alumno.nombre & vbCrLf & "Apellidos: " & alumno.apellido1 & _
" " & alumno.apellido2 & vbCrLf & "Fecha de nacimiento: " & alumno.fechanac _
& vbCrLf & "Sexo: " & alumno.sexo & vbCrLf & "Teléfono: " & alumno.telefono, vbInformation, "Datos Alumno"
contador_registros = contador_registros + 1
Loop
contador_registros = contador_registros - 1
MsgBox "contador_registros " & contador_registros
End Sub
Pues bien, aunque no tenga ningun registro creado, siempre me entra y me cuenta como mínimo 1 (aunque no se haya creado ninguno), y no se cual es el motivo....
Gracias por vuestra ayuda
Valora esta pregunta


0