|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
As always, your assistance in gr8ly appreci8d:
I am trying to parse part of a CSV file for to populate a comobo box: DATA.csv contains: bob,NY,123 Main StreetCode: Open "DATA.csv" For Input As #1Although I can use this to populate the Combobox it captures the entire line. How would I capture just the 2nd field (ie LONDON, NY, PARIS)?? thanks in advance |
|
#2
|
||||
|
||||
|
Hi,
try using this code: Code:
Line Input #1, lne$ strTemp = lne$ strPlace = Split(strTemp,",") ComboOffice.AddItem strPlace(1) That should give you the second value ie, Paris,NT etc. hope this helps |
|
#3
|
|||
|
|||
|
thanx nofriends, that sounded like 'mana', but
when I applied that code I keep getting a Runtime error: 9; Subscript out of rangeWhat am I missing? Quote:
|
|
#4
|
||||
|
||||
|
Hi,
that means that there is nothing in the array which means there is nothing in lne$? Or that there are no commas in lne$. what happens when u reponse.write lne$? It should work if there are values in lne$ with commas, quite strange. Our webserver is unpredictable at the moment so if I don't post again for a while, don't take it personally ![]() Hope you get it sorted. --Try using a Dim statement with strPlace and strTemp, and try putting something like "test,test1," into strTemp and see what happens. |
|
#5
|
|||
|
|||
|
What do you see when you step through your code with the debugger?
__________________
====== Doug G ====== I didn't attend the funeral, but I sent a nice letter saying I approved of it. --Mark Twain |
|
#6
|
|||
|
|||
|
That did it!
Still not sure why this didnt work initially but it's working now. I was running the code on word2000 system initially, but am now running it on XP...Is strTemp version specific?
Anyways, thanks to you both for the help! Quote:
|
![]() |
| Viewing: ASP Free Forums > Programming > Visual Basic Programming > VBA: reading part of CSV Line |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|