|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
problem with string function in vb.netI am using this function :
Dim ArrColWidths() As String ArrColWidths = Split(string.empty,";") 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 ? 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 Show quoteHide quote "giannik" <gian***@freemail.gr> schreef in bericht news:u8qjUQbnGHA.5096@TK2MSFTNGP03.phx.gbl... >I am using this function : > Dim ArrColWidths() As String > > ArrColWidths = Split(string.empty,";") > > 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 > ? > > > > > > 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(ArrColWidths) I get back =1 when I would like to get back zero or nothing. giannik Show quoteHide quote "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message news:%235Bqi9bnGHA.1652@TK2MSFTNGP02.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" <gian***@freemail.gr> schreef in bericht > news:u8qjUQbnGHA.5096@TK2MSFTNGP03.phx.gbl... >>I am using this function : >> Dim ArrColWidths() As String >> >> ArrColWidths = Split(string.empty,";") >> >> 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 >> ? >> >> >> >> >> >> > > giannik wrote:
> I am using this function : But exactly as documented:> Dim ArrColWidths() As String > > ArrColWidths = Split(string.empty,";") > > This always returns an array with 1 element . > > Silly in my opinion. >> If Expression is a zero-length string (""), Split returns asingle-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 justlisted explicitly for ... well, explicitness, I suppose. > Wrap it in your own function that does what you want.> Is there a way around this so that it returns an array with zero elements ? 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 |
|||||||||||||||||||||||