By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,652 Members | 1,337 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,652 IT Pros & Developers. It's quick & easy.

How to remove an empty array ?

P: n/a
how would i remove the empty array this is my function
Private Function FindMeter(ByVal txt As String) As MeterAccountName
Dim TempTxt(3) As String
TempTxt = Strings.Split(Trim(Right(txt, InStr(txt, ":") - 1)),
" ")

FindMeter.Meter = TempTxt(1)
FindMeter.xName = TempTxt(2)
FindMeter.Account_No = TempTxt(3)

End Function

Jul 13 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Rohan wrote:
how would i remove the empty array this is my function
Private Function FindMeter(ByVal txt As String) As MeterAccountName
Dim TempTxt(3) As String
TempTxt = Strings.Split(Trim(Right(txt, InStr(txt, ":") - 1)),
" ")

FindMeter.Meter = TempTxt(1)
FindMeter.xName = TempTxt(2)
FindMeter.Account_No = TempTxt(3)

End Function
The Split method of the String class allows for filtering out empty
entries, but only when passed an array of Char or String:

Function FilteredSplit(Text As String, Sep As Char) As String()

Return Text.Split(New Char() {Sep}, _
StringSplitOptions.RemoveEmptyEntries)

End Function
Private Function FindMeter(ByVal txt As String) As MeterAccountName
Dim TempTxt(3) As String
'Hmmm, wouldn't it be InStrRev(Text, ":") + 1 ?
TempTxt = FilteredSplit(Right(Text, InStr(Text, ":") - 1), " "c)
>
FindMeter.Meter = TempTxt(1)
FindMeter.xName = TempTxt(2)
FindMeter.Account_No = TempTxt(3)

End Function
HTH.

Regards,

Branco.

Jul 13 '06 #2

P: n/a
>how would i remove the empty array this is my function
What do you mean by removing the array? Keep in mind that .NET is a
garbage collected environment. You don't explicitly delete objects,
the garbage collector does that for you eventually.
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Jul 13 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.