473,569 Members | 2,834 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Delimiter question

gn
I am trying to parse a txt file which looks something like example
below:

th*******@email .com
th*******@email .com
an**********@em ail.com

This is the code I am using:

filetoread = file1.Value
filestream = File.OpenText(f iletoread)
readcontents = filestream.Read ToEnd()
textdelimiter = " "
Dim splitout = Split(readconte nts, textdelimiter)
Dim i As Integer
For i = 0 To UBound(splitout )
lblsplittext.Te xt &= "<b>Split </b>" & i + 1 & ") " & splitout(i)
& "<br>"
Next

This works fine if the file is in the format:

th*******@email .com th*******@email .com an**********@em ail.com

But what delimiter should I use to indicate a new line as a delimiter?

Thank you in advance...

Mar 2 '06 #1
4 1138
You can use Environment.New Line.

Mar 2 '06 #2
gn
Thank you,

But how would I use that in the above code?

Mar 2 '06 #3
I made a small function to test the my answer before I sent it. The
code is different (more DotNetish), but you are welcome to it =)

Import the following libraries at the top of your code:

Imports System.IO
Imports System.Text

Here was my method:

Dim FileName As String = "test.txt"
Dim FileContents As String
Dim sr As StreamReader

Try
sr = File.OpenText(F ileName)
FileContents = sr.ReadToEnd()
Catch ex As Exception
MessageBox.Show ("Unable top open file: " & ex.Message)
Return
Finally
If (sr Is Nothing) = False Then
sr.Close()
End If
End Try

Dim Lines() As String = Split(FileConte nts,
Environment.New Line)
Dim Output As New StringBuilder
Dim i As Integer
For i = 0 To Lines.Length - 1
Output.Append(" <b>Split </b>" & i + 1 & ") " & Lines(i) &
"<br />")
Next

lblSplitterText .Text = Output.ToString

Mar 2 '06 #4
gn
Thank you so much - Perfect!

Mar 2 '06 #5

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

Similar topics

3
14389
by: Laurent | last post by:
Hello, is it possible to read a file in python line by line by redefining a new end-of-line delimiter ? I would like for example to have the string "END" being the new delimiter for each line. Thanks
1
3318
by: Alan Zhong | last post by:
hi, i had been removed the row counts and the column spaces... but i failed to remove the extra tabs between rows of data return from the osql output. how to detect the row delimiter? i noticed i can use bcp to have a more decent output file, but i don't want to do too much of file read-write. the programming enviroment is quite easy to...
7
4071
by: Generic Usenet Account | last post by:
I am trying to set up a delimiter character string for the input stream such that the delimiter string is "skipped over" in the input stream. Can someone suggest how to do this with some sample code? I am attaching a "C" code snippet that does the same thing. The problem is that I don't know how to realize this using "cin" Thanks, Lee
4
11488
by: Raquel | last post by:
Could someone explain to me what the reason is for having a character delimiter (which is double quotes by default) for performing Loads/Imports on UDB? I would think that column delimiter along should have sufficed (of course it is the responsibility of the person performing the Load to ensure that the character he has chosen as column...
9
13728
by: _link98 | last post by:
Normally I use the semicolon for statement delimiters in plain SQL scripts (for DDL, simple DML etc.). But inside SQL/PL I tend to use % or @ as statement delimiters. But other people prefer other delimiters. I know that I can use the CLP option "-td" to specify the delimiter on the command line, when invoking the script. But this...
3
4046
by: magix | last post by:
Dear Guru, I have been thinking hard on how to token based on demiliter after certain position. Example, I have list of possible string below, and the the delimiter is "1" with the rules below - if the 5th character is "1", then it is delimiter elseif the 7th character is "1", then it is delimiter else this string is not a valid string
2
2680
by: pengb | last post by:
Hello All: A pretty frustrating question to ask! I use the string something = stringx.split (delimiter.tochararray()) mathod to delimit a long string by space! So supposely if the stringx is : " something something1 something2 " I should get string = something, string = something1...etc However question comes what happens if the string...
4
3412
by: kretik | last post by:
I've been trying to coax this class to use something other than the default '$' but it seems setting it to something else has no discernible effect. Is it necessary to inherit from the class to do this? I've only been using Python for a couple of weeks so I'm not sure what the best approach is here. Thanks in advance.
11
3100
by: Sven Reuter | last post by:
Hallo NG, ich versuche gerade ein PHP-Script zu bauen, das einen Trigger in einer MySQL-Datenbank erstellt. Doch leider funktioniert das nicht und ich habe auch über google keine Hinweise gefunden. Ich vermute, dass es am Delimiter liegt. Der Code, der per PHP abgeschickt wird:
0
7693
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7917
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8118
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7665
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7962
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5501
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3651
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1207
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
933
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.