SOLUCIÓN EXAMEN INFORMÁTICA JUNIO 2007. Private Sub cmdBuscar_Click(Index As Integer) ‘Buscar With Me.CommonDialog1 .FileName = "" Select Case Index Case 0 .DialogTitle = "Abrir base de datos" .Filter = "Bases de datos (*.mdb)|*.mdb" Case 1 .DialogTitle = "Abrir fichero de observaciones" .Filter = "Ficheros de observaciones (*.txt)|*.txt" End Select .ShowOpen txtNombre(Index) = .FileName End With End Sub Private Sub cmdOK_Click(Index As Integer) Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & txtNombre(0).Text Adodc1.RecordSource = "SELECT * FROM OBS" Adodc1.Refresh With Adodc1.Recordset Select Case Index Case 0 'Importar Dim tira As String Open txtNombre(1).Text For Input As 1 Line Input #1, tira While EOF(1) = False .AddNew ‘ .Fields(0).Value = Val(Mid(tira, 1, 15)) .Fields(0).Value = Val(Mid(tira, 1, 15)) .Fields(1).Value = Val(Mid(tira, 16, 14)) .Fields(2).Value = CDbl(Val(Mid(tira, 30, 14))) .Fields(3).Value = Val(Mid(tira, 44, 14)) .Fields(4).Value = Val(Mid(tira, 58, 14)) .Fields(5).Value = Val(Mid(tira, 72, 14)) .Fields(6).Value = Val(Mid(tira, 86, 14)) .Update Line Input #1, tira Wend Case 1 'Exportar Open txtNombre(1).Text For Output As 1 While .EOF = False Print #1, .Fields(0).Value, .Fields(1).Value, .Fields(2).Value, .Fields(3).Value, .Fields(4).Value, .Fields(5).Value, .Fields(6).Value .MoveNext Wend End Select End With Close 1 MsgBox "Trabajo terminado" End Sub