473,405 Members | 2,141 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

String Tokenizing - Help!

Ark
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
Apr 14 '06 #1
2 1468
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
Apr 14 '06 #2
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

"Ark" <ah 09763@yahoo-com> wrote in message
news:OY**************@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

Apr 14 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Justin L. Kennedy | last post by:
I am looking for a function that takes in a string and splits it using a list of other strings (delimiters) and can return the delimiters as well as the extra parts of the string. I was trying the...
4
by: beliavsky | last post by:
The code for text in open("file.txt","r"): print text.replace("foo","bar") replaces 'foo' with 'bar' in a file, but how do I avoid changing text inside single or double quotes? For making...
11
by: wreckingcru | last post by:
I'm trying to tokenize a C++ string with the following code: #include <iostream> #include <stdio> #include <string> using namespace std; int main(int argc, char* argv)
2
by: ES Kim | last post by:
Hi everyone, Sometimes I need to tokenize a string and convert it into some value. For example, "123.45" with predifined width 2/4 and type int/double should be converted into an int 2 and a...
16
by: Amit Gupta | last post by:
Hi - I get a seg-fault when I compile and run this simple program. (seg-fault in first call to strtok). Any clues? My gcc is "gcc version 4.1.1 20070105 (Red Hat 4.1.1-51)" #include...
2
by: Acolyte | last post by:
I'm working on a program that, eventually, is supposed to uncompress a text file where words are replaced by numbers. However, before I get to that part, I need a hand with reading in the text from a...
11
by: Lothar Behrens | last post by:
Hi, I have selected strtok to be used in my string replacement function. But I lost the last token, if there is one. This string would be replaced select "name", "vorname", "userid",...
10
by: Hank Stalica | last post by:
I'm having this weird problem where my code does the following conversion from string to float: 27000000.0 -27000000.00 2973999.99 -29740000.00 2989999.13 -2989999.25 The number on the left...
4
by: dhirenved | last post by:
hi, i have to use string tokenizing to isolate commands and the arguments that i have to execute using the execvp command. here is what i'm using char* token; char buf; printf("enter command");...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.