|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Delimiter questionbelow: thisem***@email.com thatem***@email.com anotherem***@email.com This is the code I am using: filetoread = file1.Value filestream = File.OpenText(filetoread) readcontents = filestream.ReadToEnd() textdelimiter = " " Dim splitout = Split(readcontents, textdelimiter) Dim i As Integer For i = 0 To UBound(splitout) lblsplittext.Text &= "<b>Split </b>" & i + 1 & ") " & splitout(i) & "<br>" Next This works fine if the file is in the format: thisem***@email.com thatem***@email.com anotherem***@email.com But what delimiter should I use to indicate a new line as a delimiter? Thank you in advance... 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(FileName) 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(FileContents, Environment.NewLine) 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
delete row from dataview
Problem: Unwanted Paper feed after printing. SELECT @@IDENTITY File test Modules in 2005 fonts at runtime Property 'FlowBreak' accessible only at design mode ? Read a text file word by word Intermittent VS.Net Pauses during VB.NET code writing Detecting Terminal Server in VB.Net |
|||||||||||||||||||||||