|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How to remove an empty array ?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 Rohan wrote:
> how would i remove the empty array this is my function The Split method of the String class allows for filtering out empty> > > 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 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 'Hmmm, wouldn't it be InStrRev(Text, ":") + 1 ?> Dim TempTxt(3) As String TempTxt = FilteredSplit(Right(Text, InStr(Text, ":") - 1), " "c) > HTH.> FindMeter.Meter = TempTxt(1) > FindMeter.xName = TempTxt(2) > FindMeter.Account_No = TempTxt(3) > > End Function Regards, Branco. >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 agarbage 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.
Lookup table in a Label
is Recursive Procedures/Function what i need to solve my problem? consume web service via httpwebrequest Making Tag with Web.UI.Control Limit to range of colors displayed by Label control? Batch file question Transitioning to VB.NET forum Getting a non-activity trigger from XP Writing a Browser Helper Object in VB6 |
|||||||||||||||||||||||