AccessTr.neT
Txt Dosyasından Bilgi Alma - Baskı Önizleme

+- AccessTr.neT (https://accesstr.net)
+-- Forum: Microsoft Access (https://accesstr.net/forum-microsoft-access.html)
+--- Forum: Access Cevaplanmış Soruları (https://accesstr.net/forum-access-cevaplanmis-sorulari.html)
+--- Konu Başlığı: Txt Dosyasından Bilgi Alma (/konu-txt-dosyasindan-bilgi-alma--89797.html)

Sayfalar: 1 2 3 4 5 6


RE: Txt Dosyasından Bilgi Alma - yenginoglu - 23/06/2022

Hocam merhaba,

001,00001,1 2022/06/21 09:59:43 000
cihazno, sicilno, gc, gtarih, gsaat, nedeni

Saygılarımla,


RE: Txt Dosyasından Bilgi Alma - berduş - 23/06/2022

eklediğiniz dosyada nedeni alanı yada ona benzer metin alanı olmadığı için sadece nedeni alanı dışındakileri ekledim
Sub OpenTextFileTest()
Dim result As Integer
On Error GoTo Err

yol = getFileName

Response = MsgBox("Dosya bulundu verileri yüklemek ister misiniz?", vbYesNo, "UYARI")
If Response = 7 Then Exit Sub

Dim strTextLine As String
Dim iFile As Integer: iFile = FreeFile
Open yol For Input As #iFile
Do Until EOF(1)
Line Input #1, strTextLine
tmpdz = Split(strTextLine)
sonuc = tmpdz(0) & ",#" & tmpdz(1) & "#,#" & tmpdz(2) & "#" 'cihazno,sicilno,gc,gtarih,gsaati,ctarihi,csaati
CurrentDb.Execute ("insert into tblAlınanVeriler (cihazno,sicilno,gc,gtarih,gsaati) values (" & sonuc & ") ")
Loop
Close #iFile
msgbox "bitti"
Err:
If Err.Number = 62 Then
MsgBox "Belirttiğiniz dosya boş", vbOKOnly, "UYARI"
Else
End If
Exit Sub

Çıkış:
End Sub



RE: Txt Dosyasından Bilgi Alma - yenginoglu - 23/06/2022

Hocam çok teşekkür ederim. Sağolun,

Saygılarımla,


RE: Txt Dosyasından Bilgi Alma - berduş - 23/06/2022

rica ederim
iyi çalışmalar


RE: Txt Dosyasından Bilgi Alma - yenginoglu - 14/07/2023

Berduş Hocam merhaba,

aynı txt dosyasından Excel e nasıl verileri alabilirim.

Saygılarımla,


RE: Txt Dosyasından Bilgi Alma - atoykan - 14/07/2023

Kod:
Sub OpenTextFileTest()
    On Error GoTo ErrHandler

    Dim yol As String
    Dim Response As Variant
    Dim strTextLine As String
    Dim tmpdz As Variant
    Dim sonuc As String
    Dim iFile As Integer
    
    yol = getFileName
    
    Response = MsgBox("Dosya bulundu verileri yüklemek ister misiniz?", vbYesNo, "UYARI")
    If Response = vbNo Then Exit Sub
    
    iFile = FreeFile
    Open yol For Input As #iFile
    
    Do Until EOF(iFile)
        Line Input #iFile, strTextLine
        tmpdz = Split(strTextLine)
        sonuc = tmpdz(0) & ",#" & tmpdz(1) & "#,#" & tmpdz(2) & "#"
        ThisWorkbook.Sheets("Sheet1").Range("A1").CurrentRegion.ListObject.ListRows.Add AlwaysInsert:=True
        ThisWorkbook.Sheets("Sheet1").Range("A1:C1").Value = Split(sonuc, ",")
    Loop
    
    Close #iFile
    MsgBox "bitti"
    
ErrHandler:
    If Err.Number = 62 Then
        MsgBox "Belirttiğiniz dosya boş", vbOKOnly, "UYARI"
    End If
End Sub

şeklinde excele uyarlayabilirsiniz.