472,357 Members | 1,937 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

Splitting a String

Using Vb.net 2005,
I want to read each part in this string in an array (splitting the string)
A1/EXT "BK82 LB73 21233" 105 061018 1804
That Code that i used is as follow:

Dim s As String, h As String
Dim delim(1) As Char
delim(0) = "/"
delim(1) = " "

Dim f() As String
s = A1/EXT ""BK82 LB73 21233"" 105 061018 1804
f = s.Split(delim)
The problem that I m facing is as follow :
even what is inside the double quotes is devided into parts
what should i add to my code (or any other solution),
in order to keep what is inside the "" with splitting
Oct 29 '06 #1
2 1381
Hi, You contacted me off-forum re this one, so I was a bit surprised and confused about why you've gone about your second code block in such a roundabout way.

A very small variation of what I suggested seems to work just fine. That is, it finds the quotes, removes them, pulls out the block of code you wanted to select and displays it.

Expand|Select|Wrap|Line Numbers
  1. Dim result As New ArrayList
  2.         Dim checkStr As String = "A1/EXT ""BK82 LB73 21233"" 105 061018 1804"
  4.         If checkStr.Contains(Chr(34)) Then
  5.             Dim first As Integer = checkStr.IndexOf(Chr(34)) + 1
  6.             Dim last As Integer = checkStr.LastIndexOf(Chr(34))
  7.             result.Add(checkStr.Substring(first, last - first))
  8.         End If
  9.         For Each s2 As String In result
  10.             Console.WriteLine(s2)
  11.         Next
Hope this helps
Oct 29 '06 #2
Sorry, forgot to mention that this line in your code sample:

s = A1/EXT ""BK82 LB73 21233"" 105 061018 1804

won't compile because you need to enclose the whole string in quotes.

(I made that change in my suggestion in the previous post)
Oct 29 '06 #3

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

Similar topics

by: qwweeeit | last post by:
Splitting with RE has (for me!) misterious behaviour! I want to get the words from this string: s= 'This+(that)= a.string!!!' in a list like that considering "a.string" as a word. Python...
by: fatted | last post by:
I'm trying to write a function which splits a string (possibly multiple times) on a particular character and returns the strings which has been split. What I have below is kind of (oh dear!)...
by: JeffM | last post by:
Quick C# question: I have comma delimited values in a string array that I want to pass to seperate variables. Any tips on splitting the array? Thanks in advance! JM
by: Trint Smith | last post by:
Ok, My program has been formating .txt files for input into sql server and ran into a problem...the .txt is an export from an accounting package and is only supposed to contain comas (,) between...
by: Opettaja | last post by:
I am new to c# and I am currently trying to make a program to retrieve Battlefield 2 game stats from the gamespy servers. I have got it so I can retrieve the data but I do not know how to cut up...
by: HMS Surprise | last post by:
The string s below has single and double qoutes in it. For testing I surrounded it with triple single quotes. I want to split off the portion before the first \, but my split that works with...
by: shadow_ | last post by:
Hi i m new at C and trying to write a parser and a string class. Basicly program will read data from file and splits it into lines then lines to words. i used strtok function for splitting data to...
by: yogi_bear_79 | last post by:
I have a simple string (i.e. February 27, 2008) that I need to split into three parts. The month, day, and year. Splitting into a string array would work, and I could convert day and years to...
by: xyz | last post by:
I have a string 16:23:18.659343 tcp 168 for example lets say for the above string 16:23:18.659343 -- time -- srcaddress 22 ...
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. header("Location:".$urlback); Is this the right layout the...
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and...
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and credentials and received a successful connection...
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...

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.