problem with string function in vb.net

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • giannik

    #1

    problem with string function in vb.net

    I am using this function :
    Dim ArrColWidths() As String

    ArrColWidths = Split(string.em pty,";")

    This always returns an array with 1 element .

    Silly in my opinion.

    Is there a way around this so that it returns an array with zero elements ?






  • Cor Ligthert [MVP]

    #2
    Re: problem with string function in vb.net

    giannik, what do you expect than,

    What you write is (exactly) the same as

    ArrColWidths = Split("",";")

    I assume tht this is not your goal?

    Cor

    "giannik" <giannik@freema il.grschreef in bericht
    news:u8qjUQbnGH A.5096@TK2MSFTN GP03.phx.gbl...
    >I am using this function :
    Dim ArrColWidths() As String
    >
    ArrColWidths = Split(string.em pty,";")
    >
    This always returns an array with 1 element .
    >
    Silly in my opinion.
    >
    Is there a way around this so that it returns an array with zero elements
    ?
    >
    >
    >
    >
    >
    >

    Comment

    • giannik

      #3
      Re: problem with string function in vb.net

      coming from vb 6 environment, the split function would return an empty
      array.
      Since I am passing an empty string (nothing ) I would expect also that
      the array would contain nothing in it.
      giannik

      I wish to be able to parse a string with the split function
      and then take some action according to if the array is empty or not.
      Now if i choose ubound(ArrColWi dths) I get back =1 when I would like to get
      back zero or nothing.
      giannik


      "Cor Ligthert [MVP]" <notmyfirstname @planet.nlwrote in message
      news:%235Bqi9bn GHA.1652@TK2MSF TNGP02.phx.gbl. ..
      giannik, what do you expect than,
      >
      What you write is (exactly) the same as
      >
      ArrColWidths = Split("",";")
      >
      I assume tht this is not your goal?
      >
      Cor
      >
      "giannik" <giannik@freema il.grschreef in bericht
      news:u8qjUQbnGH A.5096@TK2MSFTN GP03.phx.gbl...
      >>I am using this function :
      >Dim ArrColWidths() As String
      >>
      >ArrColWidths = Split(string.em pty,";")
      >>
      >This always returns an array with 1 element .
      >>
      >Silly in my opinion.
      >>
      >Is there a way around this so that it returns an array with zero elements
      >?
      >>
      >>
      >>
      >>
      >>
      >>
      >
      >

      Comment

      • Larry Lard

        #4
        Re: problem with string function in vb.net


        giannik wrote:
        I am using this function :
        Dim ArrColWidths() As String
        >
        ArrColWidths = Split(string.em pty,";")
        >
        This always returns an array with 1 element .
        >
        Silly in my opinion.
        But exactly as documented:
        >>
        If Expression is a zero-length string (""), Split returns a
        single-element array containing a zero-length string. If Delimiter is a
        zero-length string, or if it does not appear anywhere in Expression,
        Split returns a single-element array containing the entire Expression
        string.
        >>
        In fact the first case here is covered by the second case; it's just
        listed explicitly for ... well, explicitness, I suppose.

        >
        Is there a way around this so that it returns an array with zero elements ?
        Wrap it in your own function that does what you want.

        What would you want Split("banana", ";") to return, incidentally ?

        --
        Larry Lard
        Replies to group please
        When starting a new topic, please mention which version of VB/C# you
        are using

        Comment

        Working...