473,385 Members | 1,890 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,385 software developers and data experts.

VB.net new Line

I recieve a string, which consists of multiple lines, from a UDP connection.
(It's that java program I'm translating for those who have read my other topics)

Now, I need to split this string in seperate lines, but this does not seem to work.
In the java program "\n" is used as delimiter to split the string, but when I try to split (in the translated vb.net program) using VbNewLine it does not work. I also tried VbCr and VbCrLf...

I did an experiment: I used the InStr to see if VbNewLine or whatever is found in the string. Apparently none of them are found.

Are there more options to create new lines I haven't checked?
May 22 '08 #1
8 2268
Plater
7,872 Expert 4TB
You could use .Split() on the string and supply the '\n' character as what to split on?
May 22 '08 #2
Sick0Fant
121 100+
You could use .Split() on the string and supply the '\n' character as what to split on?
'\n' won't work in VB, will it?

Since you're working in .NET, you can assume ASCII values for characters. So do something like:

MyString.Split(Convert.ToChar(13))
May 22 '08 #3
You could use .Split() on the string and supply the '\n' character as what to split on?
No that won't work. (I tried anyway)
The "\n" is the equivalent of VbNewLine in java....
May 22 '08 #4
MyString.Split(Convert.ToChar(13))
InStr(myString, Convert.ToChar(13)) returns 0 ...
May 22 '08 #5
Sick0Fant
121 100+
InStr(myString, Convert.ToChar(13)) returns 0 ...
Maybe they are carriage returns, in which case you'd use 10 instead of 13.

If that's not in the string, then I don't know how it's delimited.
May 22 '08 #6
Plater
7,872 Expert 4TB
Stop using InStr, start using .NET syntax.

mystring.IndexOf('\n') if that doesn't return a value >-1 then there is no \n's in there.

I have a theory on what might be happening. Your UDP is probably getting in a byte[] right? ( byte() whatever they call it in vb)
How are you converting it to a string?
May 22 '08 #7
Maybe they are carriage returns, in which case you'd use 10 instead of 13.

If that's not in the string, then I don't know how it's delimited.
Console.WriteLine("Index: " & queryResult.IndexOf(Convert.ToChar(10)))

prints out Index 80!
yes! It's carriage return apparently, thank you.

@Plater, Thanx for the help, but please explain why IndexOf is better than InStr?
May 22 '08 #8
Plater
7,872 Expert 4TB
It's an actual .NET function. If you're going to program in managed code (instead of vb6 for example) why not use it? Plus it's easier to read since it matches with other .NET code, so for future questions people won't have to decipher things like Mid(), InStr(), etc, etc.
May 22 '08 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Peter A. Schott | last post by:
Per subject - I realize I can copy/paste a line at a time into an interactive session when I'm trying to debug, but was wondering if there is any tool out there that allows me to copy sections of...
65
by: Skybuck Flying | last post by:
Hi, I needed a method to determine if a point was on a line segment in 2D. So I googled for some help and so far I have evaluated two methods. The first method was only a formula, the second...
22
by: DraguVaso | last post by:
Hi, For my application I need the following behavior: When I press F4 the cursor has to move to the next line in my multiline textbox which begins with "0". Finding lines starting with 0 isn't...
3
by: Double Echo | last post by:
Hi all, I'm using PHP 4.4.2, and use PHP on both the command-line and the web. I am running PHP on SuSE 10 Linux , in a VMware 5.5 workstation, using Apache 2.0.55 , on my Dell laptop. ...
9
by: Adi | last post by:
Hello eveyone, I wanna ask a very simple question here (as it was quite disturbing me for a long time.) My problem is to read a file line by line. I've tried following implementations but still...
6
by: magix | last post by:
Hi, when I read entries in file i.e text file, how can I determine the first line and the last line ? I know the first line of entry can be filtered using counter, but how about the last line...
6
by: Jacob Rael | last post by:
Hello, I have a simple script to parse a text file (a visual basic program) and convert key parts to tcl. Since I am only working on specific sections and I need it quick, I decided not to...
14
by: WStoreyII | last post by:
the following code is supposed to read a whole line upto a new line char from a file. however it does not work. it is producing weird results. please help. I had error checking in there for...
11
by: xdevel | last post by:
Hi, I don't understand option. if I write: #line 100 "file" I change file numeration to start to line 100 but what "file" ? any example?
19
by: =?Utf-8?B?QnJpYW4gQ29vaw==?= | last post by:
This is an example of the data; 2007/07/27 11:00:03 ARES_INDICATION 010.050.016.002 404.2.01 (6511) RX 74 bytes 2007/07/27 11:00:03 65 11 26 02 BC 6C AA 20 76 93 51 53 50 76 13 48...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...

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.