OK guys, I apologise for the potential simplicity of this one, but I cannot get my head around it - Sorry!
I need to read in a csv file, and from it, create notes documents. Everything is fine, apart from not all fields in the csv file are populated, so you can end up with lines as follows:
1,2,3,8,10
If I try to read this file in, I get a type-mismatch error.
Can anyone tell me how I can do this, without modifying the csv file beforehand.
Thanks,
Darren
Here is the code I am currently using:
Dim arrayOfRecs() As RecType
Dim fileNum As Integer
fileNum = Freefile()
Open “file.txt” For Input As fileNum
Dim txt As String
Dim counter As Integer
Dim countRec As Integer
Do While Not Eof( fileNum )
Line Input #fileNum, txt
counter = counter + 1
Loop
Seek fileNum, 1
Redim arrayOfRecs( 1 To counter )
countRec = 1
While Not Eof( fileNum )
Input #fileNum, _
arrayOfRecs( countRec ).RecordType, _
arrayOfRecs( countRec ).ClientNumber, _
arrayOfRecs( countRec ).PolicyNumber, _
arrayOfRecs( countRec ).InceptionDate, _
arrayOfRecs( countRec ).ExpiryDate, _
arrayOfRecs( countRec ).LastRenewal, _
arrayOfRecs( countRec ).CurrentRenewal, _
arrayOfRecs( countRec ).EffectiveDate, _
arrayOfRecs( countRec ).Title, _
arrayOfRecs( countRec ).Initials, _
arrayOfRecs( countRec ).Surname, _
arrayOfRecs( countRec ).RishHouse, _
arrayOfRecs( countRec ).RiskStreet, _
arrayOfRecs( countRec ).RiskLocality, _
arrayOfRecs( countRec ).RiskCity, _
arrayOfRecs( countRec ).RiskCounty, _
arrayOfRecs( countRec ).RiskPostCode, _
arrayOfRecs( countRec ).DateOfBirth, _
arrayOfRecs( countRec ).InsuredAge, _
arrayOfRecs( countRec ).Occupation, _
arrayOfRecs( countRec ).BuildArea, _
arrayOfRecs( countRec ).ContentsArea, _
arrayOfRecs( countRec ).YearPropertyBuilt , _
arrayOfRecs( countRec ).TypeOfProperty, _
arrayOfRecs( countRec ).NoOfBedrooms, _
arrayOfRecs( countRec ).RoofConstruction, _
arrayOfRecs( countRec ).WallConstruction, _
arrayOfRecs( countRec ).TypeOfCover, _
arrayOfRecs( countRec ).Security, _
arrayOfRecs( countRec ).AccDamageContents, _
arrayOfRecs( countRec ).AccDamageBuildings, _
arrayOfRecs( countRec ).PersonalBelongings, _
arrayOfRecs( countRec ).NoClaimsDiscount, _
arrayOfRecs( countRec ).ContentsSumInsured, _
arrayOfRecs( countRec ).BuildingsSumInsured, _
arrayOfRecs( countRec ).CorrespondenceHouse, _
arrayOfRecs( countRec ).CorrespondenceStreet, _
arrayOfRecs( countRec ).CorrespondenceLocality, _
arrayOfRecs( countRec ).CorrespondenceCity, _
arrayOfRecs( countRec ).CorrespondenceCounty, _
arrayOfRecs( countRec ).CorrespondencePostCode, _
arrayOfRecs( countRec ).Endorsement1, _
arrayOfRecs( countRec ).Endorsement2, _
arrayOfRecs( countRec ).Endorsement3
countRec = countRec + 1
Wend
Close fileNum