Make ";" act like ","

Hope you can help out a poor novice. I have a text file with a list of names separated by “,” and grouped using “;”. And this works great populating my listbox. I would like to use the same file to list the names in a combo box without the grouping aspect of the “;”. The code I have works except for the “;” which of course which gives this: Yellow-billed Loon;Red-necked Grebe. Just want the “;” to delimit like “,” in those cases. I tried a few things but nothing. Am I even thinking about it the right way? My code is below. Thanks

Dim s As String
Dim i, last As Integer
Dim f As folderItem
Dim TextIn As TextInputStream
dim myText As String

f=GetFolderItem(“Species File”)

////Get Species names
if f<>nil then
TextIn=TextInputStream.open(f)
myText=TextIn.readLine
s=myText
end if

////Parse Species name file
last = CountFields(s,",")
For i = 1 To last
Me.AddRow(NthField(s, “,”, i))
Next
Me.ListIndex = -1

// - get species names
if f <> nil then
textIn = textInputStream.open(f)
myText = textIn.readLine
myText = replaceAll(myText, “;”, “,”)
s = myText
end if

Sweet, thanks for your time!

Beware of data structures like:

THIS IS ONE OF MY DATA;THIS IS ANOTHER ONE;THIS IS ANOTHER ONE, BUT THIS TIME, IT CONTAINS COMMAS;THIS IS THE LAST ONE

[quote=64339:@Rick Araujo]Beware of data structures like:

THIS IS ONE OF MY DATA;THIS IS ANOTHER ONE;THIS IS ANOTHER ONE, BUT THIS TIME, IT CONTAINS COMMAS;THIS IS THE LAST ONE[/quote]

I would do :

  • a replaceAll(myText, “,”, “$$”),
  • then proceed with the replaceAll(myText, “;”, “,”)
  • then parse, and in each field replaceAll(fieldvariable, “$$”, “,”)

Should do the trick in case comas are used in a field…

Rick and Michel, I do see what you mean. In this case the user won’t control what goes into the file. But I do have a field in my database where user commas will cause problems. Thanks.