|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
String Tokenizing - Help!Hello,
I have a text file that has each line that is comma seperated, and I need to get the values into an array. I have worked with Java and have used StringTokenizer, but have been looking for that kind of thing in Vb.NET. Will appreciate any advice on what to use, thanks!! Ark String.Split is not exactly the same but it does the job. To get lines
you can use: Dim lines() As String 'use VB Split instead of System.Split for 2-char long delimiter lines = Split(myString, vbCrLf) To get values on one line: Dim tokens() As String tokens = line.Split(","c) To get values from all lines: Dim tokens() As String 'String.Split only accepts one char long delimiters, so modify '2-char vbcrlf to vbcr myString = myString.Replace(vbCrLf, Chr(13)) tokens = myString.Split(New [Char]() {","c, Chr(13)}) -- Peter Macej Helixoft - http://www.vbdocman.com VBdocman - Automatic generator of technical documentation for VB, VB ..NET and ASP .NET code Dim sr As New System.IO.StreamReader("TestFile.txt")
Dim line As String = sr.ReadLine() While line IsNot Nothing Dim values() As String = line.Split(","c) line = sr.ReadLine() End While /claes Show quoteHide quote "Ark" <ah 09763@yahoo-com> wrote in message news:OYj6r53XGHA.4060@TK2MSFTNGP02.phx.gbl... > Hello, > > I have a text file that has each line that is comma seperated, and I need > to get the values into an array. I have worked with Java and have used > StringTokenizer, but have been looking for that kind of thing in Vb.NET. > Will appreciate any advice on what to use, thanks!! > > Ark >
How to release a free source code?
Dynamically open forms, reports or call functions .NET 1.1 app runs on .NET 2.0? Warning Text Files Access Crystal "PrintToPrinter" will not print to Zebra Label Printer... HELP! Database update problems. How to convert a regular VB app into a service to run on a Windows 2003 server? IO.File.AppendText error FileUpload to SQL Crypto Question |
|||||||||||||||||||||||