How to use parts of a String

  • Thread starter Thread starter thomasc1020
  • Start date Start date
T

thomasc1020

This discussion is about VB.NET 2003.

Suppose we received 300 bytes input from a serial port, which are
numbered as B001, B002,..., B300.

I want to save all 300 bytes and diplay only parts of the input, say,
B037 to B060, and B113 to 396.
Now I am using a String to buffer the input. But I have no idea how to
pick out and display parts of the String.

Should I use a String array to do this?
What would be the best way to design the code for such operation?

Please help.
Thank you!
 
This discussion is about VB.NET 2003.

Suppose we received 300 bytes input from a serial port, which are
numbered as B001, B002,..., B300.

I want to save all 300 bytes and diplay only parts of the input, say,
B037 to B060, and B113 to 396.
Now I am using a String to buffer the input. But I have no idea how to
pick out and display parts of the String.

Should I use a String array to do this?
What would be the best way to design the code for such operation?

Please help.
Thank you!

Look up the String class in 'Help' and you'll see the String has many
properties and methods you can work with.
And google will respond with examples galore - here's one:
http://www.vbdotnetheaven.com/UploadFile/mahesh/StringsinDotnet04212005074227AM/StringsinDotnet.aspx
 
Thomas,

Accoording to your message, I would probably use multithreading to get the
strings from the serial port.
Put them in a Queue, then get the strings from the Queue in the main
application and then it depend.

If I would like to save them, I would just set them in a simple datatable
and add that to a database
else I would put them in a simple List/Collecton to save them for processing
or maybe I would use the simple arraylist.

http://msdn2.microsoft.com/en-us/library/system.collections.queue(VS.71).aspx

Probably I would try with this the stringcollection which I never have used
to overcome casting all the time.
http://msdn2.microsoft.com/en-us/library/system.collections.specialized.stringcollection(vs.71).aspx

For how to handle the individual strings, have a look at the reply from Hal.

Cor
 
Back
Top