Re: Splitting a String

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



On Fri, 19 May 2006 20:33:29 -0400, "Nicholas Paldino [.NET/C# MVP]"
<mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:

Materialised,

Why not just do this?

public static int[] SplitBarCode(string barcode)
{
// The return value.
int[] retVal = new int[4];

// Split the string.
retVal[0] = Int32.Parse(barcode.Substring(0, 2));
retVal[1] = Int32.Parse(barcode.Substring(2, 5));
retVal[2] = Int32.Parse(barcode.Substring(7, 5));
retVal[3] = Int32.Parse(barcode.Substring(12, 1));

// Return the value.
return retVal;
}

Of course, you might want to put a little more error handling into this,
but this should do it.

Hope this helps.

Use regular expression (RegEx class) and its Split method!.
--
Ludwig Stuyck
http://www.coders-lab.be
.



Relevant Pages

  • Re: Splitting a String
    ... public static int[] SplitBarCode ... I have a string value (it actually represents a barcode) which looks like ... The placement of the values is actually fixed, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: DDE Between Access ADP and B-Coder Pro not working in win2k
    ... barcode format, and the link you gave seems to only have the Code 39 format. ... The ADP generates barcodes by passing the ... >>Function BarCodeTbl(MyTextField As String, ... >> If Err Then Exit Function ...
    (microsoft.public.win2000.security)
  • Re: DDE Between Access ADP and B-Coder Pro not working in win2k
    ... please no direct email. ... >barcode format, and the link you gave seems to only have ... >> font is this feild. ... >>>Function BarCodeTbl(MyTextField As String, ...
    (microsoft.public.win2000.security)
  • Re: Problem mit DDE
    ... Im Bericht werden zwei Steuerelementen mit zwei verschiedene Barcodes ... Die Funktion Barcode (hab ich im Prinzip aus der Anleitung des ... Public Function Barcode(Nutzziffer As String _ ...
    (microsoft.public.de.access)
  • Re: Help Please - Searching a large text file
    ... barcode, which is at the beginning of each line), I would use the Filter ... Dim FoundItemsAs String ... potential for a problem if one of the items earlier in the array contains ... Write #FileNumber, Replace$, ",", vbTab) ...
    (comp.lang.basic.visual.misc)