I am trying to process a tab delimited text file, the ultimate aim to populate a table in access with the contents of each line. But I am unable to detect the "tabs" in the test file. I have tried using the split function with various arguments and also strReplace with various argument. None of them can detect a tab:
I am trying to run either procedure from the immediate window. I have tried manually typing in a string with tabs and also copying and pasting a line from a tab delimited text file. Nothing appears to work. Driving me mad!
Code:
Public Function ReplaceTabs(strInput) As String
10 On Error GoTo err_ReplaceTabs
20 ReplaceTabs = Replace(strInput, vbTab, ">>><<<") 'doesn't work but should? string with tabs doesn't split
'20 ReplaceTabs = Replace(strInput, Chr(9), ">>><<<") 'also doesn't work
'20 ReplaceTabs = Replace(strInput, " ", ">>><<<") 'tab key from keyboard also doesn't work it splits on tabs but on spaces as well
exit_ReplaceTabs:
30 Exit Function
err_ReplaceTabs:
40 MsgBox Err.Number & " " & Err.Description & vbCr & vbCr & "Error Line: " & Erl
50 Call Logger("Error", "meetings.basFunctions.ReplaceTabs," & Erl, Err.Number, Err.Description)
60 Resume exit_ReplaceTabs
End Function
Code:
Public Sub SplitStringByTab(strInput As String)
'this doesnt appear to work for any attempt to split by tab unsure why
10 On Error GoTo err_SplitStringByTab
Dim arrOutput() As String
Dim i As Integer
20 arrOutput = Split(strInput, vbTab) 'doesn't work but should? string with tabs doesn't split
'20 arrOutput = Split(strInput, Chr(9)) 'doesn't work?
'20 arrOutput = Split(strInput, " ") 'tab key from keyboard also doesn't work it splits on tabs but on spaces as well
30 For i = LBound(arrOutput) To UBound(arrOutput)
40 Debug.Print i & " = " & arrOutput(i)
50 Next i
exit_SplitStringByTab:
70 Exit Sub
err_SplitStringByTab:
80 MsgBox Err.Number & " " & Err.Description & vbCr & vbCr & "Error Line: " & Erl
90 Call Logger("Error", "meetings.basFunctions.SplitStringByTab," & Erl, Err.Number, Err.Description)
100 Resume exit_SplitStringByTab
End Sub
I am trying to run either procedure from the immediate window. I have tried manually typing in a string with tabs and also copying and pasting a line from a tab delimited text file. Nothing appears to work. Driving me mad!