Using VB6, is there any special way of reading an ascii text file, that does not have any delimiters? The rows of data are seperated into seperate columns, but there is not "space" delimiter. Has me confused. I am trying to read in about 10 columns of data, with x number of rows. Any help or suggestions? Thanks
VB6 and ASCII text files
Collapse
X
-
Tags: None
-
-
This is the code I'm using to split the line:
This is the function code that processes each line:Code:strLine = TrimAll2(objstream.Readline) myarray = Split(strLine, vbTab) 'use tab to create space 'read into variables lithdepth = Format(Trim(myarray(0)), "0") shale = Trim(myarray(1)) silt = Trim(myarray(2)) sand = Trim(myarray(3)) chalk = Trim(myarray(4)) lime = Trim(myarray(5)) dolo = Trim(myarray(6)) anhy = Trim(myarray(7)) coal = Trim(myarray(8)) chert = Trim(myarray(9)) nosamp = Trim(myarray(10))
For some reason, vbTab is still giving me an error when reading the line into an assigned variable.Code:Function TrimAll2(Str) '***remove all non ASCI chrs and reduce internal whitespace to single Dim i, strTemp, strOut, strCh strTemp = Str For i = 1 To Len(strTemp) strCh = Mid(strTemp, i, 1) '***look at each character in turn '***if the chr is a space and the previous added chr was a space ignore it '***otherwise add it on If Not (strCh = " " And Right(strOut, 1) = " ") And ((Asc(strCh) >= 64 And Asc(strCh) <= 122) _ Or (Asc(strCh) >= 48 And Asc(strCh) <= 57) Or Asc(strCh) = 32 Or strCh = ".") Then strOut = strOut & strCh End If Next TrimAll2 = strOut End FunctionComment
-
So, do I need to recode the function? Or can I add to it? Or what would you suggest? Thanks for the response.Comment
-
Comment