Undetermine
(1)
Debug.assert
(1)
Valuesin
(1)
NTC
(1)

Reading csv file and parsing comma delimited values in Array

Asked By mls via AccessMonster.com
03-Feb-10 04:45 PM
I am reading a .CSV file using FileSystemObject, and one of my field (std_num
) which has null values for the first 15 rows but have a number value after
16 so how can I read that  correctly?

Dim myarray() As String
Dim temp_str As String
Dim SET1 As String
Dim STD_num As Integer

temp_str = "A1,NTC,H1,Unknown,Undetermine" ' First 15 rows
temp_str = "A1,NTC,H1,Unknown,20.3, 25.34" ' 16th row
myarray = Split(temp_str, ",")

SET1 = myarray(2)
If (IsNumeric(myarray(5))) Then
STD_num = Format(myarray(5), "####.##")
Else
STD_num = 0
End If

--
Message posted via http://www.accessmonster.com

If I understand you correctly you sometimes have 5, sometimes 6 valuesin a row.

Tom van Stiphout replied to mls via AccessMonster.com
03-Feb-10 07:09 PM
If I understand you correctly you sometimes have 5, sometimes 6 values
in a row. So test for that:
myarray = split(...)
if ubound(myarray)=4 then
'5 elements
else if ubound(myarray) = 5 then
'6 elements
else
debug.assert false  'unexpected count
end if

-Tom.
Microsoft Access MVP
Post Question To EggHeadCafe