LER ARQUIVO TXT

WBUZZO 17/03/2016 20:45:45
#459403
Resolvido:
Utilizei arquivo randômico conforme código abaixo:

Type Campos
Descricao As String * 100
Usuario As String * 40
Senha As String * 40
Observacao As String * 170
End Type

Para gerar o arquivo
Dim gRegistro As Campos
Sub gerar_arquivo(ByVal strFilename As String, ByRef msFlex As MSFlexGrid)
Dim intFreeFile As Integer
Dim r As Integer
Dim gRecordLen As Long
gRecordLen = Len(gRegistro)
intFreeFile = FreeFile
Open strFilename For Random As #intFreeFile Len = gRecordLen
With msFlex
For r = 1 To .Rows - 1
gRegistro.Descricao = .TextMatrix(r, 1)
gRegistro.Usuario = .TextMatrix(r, 2)
gRegistro.Senha = .TextMatrix(r, 3)
gRegistro.Observacao = .TextMatrix(r, 4)
Put #intFreeFile, r, gRegistro
Next r
End With
Close #intFreeFile
End Sub

Para ler o arquivo
Sub Carrega_Atualiza_Memo_MSFlexGrid()
Arq_ContrMemoDPGP = frmChave.CommonDialog1.FileName
Dim gRecordLen As Long
Dim gArq As Long
Dim C As Integer
gRecordLen = Len(gRegistro)
gArq = FileLen(Arq_ContrMemoDPGP) / gRecordLen
C = 1
Open Arq_ContrMemoDPGP For Random As #1 Len = gRecordLen
Do While C <= gArq
Get #1, C, gRegistro
MSFlexGrid1.TextMatrix(C, 1) = Trim(gRegistro.Descricao)
MSFlexGrid1.TextMatrix(C, 2) = Trim(gRegistro.Usuario)
MSFlexGrid1.TextMatrix(C, 3) = Trim(gRegistro.Senha)
MSFlexGrid1.TextMatrix(C, 4) = Trim(gRegistro.Observacao)
MSFlexGrid1.AddItem [Ô][Ô]
C = C + 1
Loop
Close #1
End Sub
Página 2 de 2 [11 registro(s)]
Tópico encerrado , respostas não são mais permitidas