I am trying to parse a sentence wherein the words are seperated by spaces. The words are then stripped of commas (",") or semicolons (";") and written to a database. This code to split the words works in VB.net 2002 but not VB.Net 2003 or 2005. Iam using streamReader/StreamWriter to read/write from a text file.
Variables:
currentSentence as String
splitSentence() as String
i as Integer
Code:
Do Until sr.Peek = -1
currentSentence = sr.readLine
For i = 1 To currentSentence.Length -1 ' Ignore first word
splitSentence = currentSentence.Split(" ")*
'Some other code to write sentence goes here
Next i
Loop
* the Split method is splitting the characters and not the words in VB.Net 2003 and 2005
Any suggestions
Thanks Trebormac

Parse a sentence in VB. Net
citegestion
The following code works as you'd expect in Visual Studio 2003, spliting words not characters.
Dim s1 As String
s1 = "ABC DEF GHI, JKL " Dim s2() As String
s2 = s1.Split(" ") For Each s As String In s2
Console.WriteLine(s)
Next
The output looks like this...
ABC
DEF
GHI,
JKL
BZRK
Dim currentSentence As String = "This is a test!!!"
Dim splitSentence() As String = currentSentence.Split(" "c)
For Each s As String In splitSentence
Console.WriteLine(s)
Next
DannyvG