Hocam merhaba,
001,00001,1 2022/06/21 09:59:43 000
cihazno, sicilno, gc, gtarih, gsaat, nedeni
Saygılarımla,
Ahmet Yenginoğlu
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
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