View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
GS[_6_] GS[_6_] is offline
external usenet poster
 
Posts: 1,182
Default Why the heck doesn't this work?

The file data.txt contains the following string:
(There's a tab char just after the a123)

a123 A. BC #123


Oh.., now you tell us! Any other *very important details* like this we need to
know?


Sub ParseTextFile2a()
Dim vTmp, sLine$
Const sFile$ = "C:\Data.txt"
sLine = ReadTextFile(sFile)
vTmp = Split(sLine, vbTab)
Debug.Print Trim(vTmp(0)) '//returns "a123"
Debug.Print Trim(vTmp(1)) '//returns "A. BC #123"
'//where the file contains "a123", a Tab followed by "A. BC #123"
vTmp = Split(vTmp(1), " ")
Dim n&
For n = LBound(vTmp) To UBound(vTmp)
Debug.Print vTmp(n)
Next 'n
'//returns
'"a123"
'"A. BC #123"
'"A."
'"BC"
'"#123"
End Sub

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion