Solved

Index was outside the bounds of the array. TextChanged

Posted on 2014-07-27
2
122 Views
Last Modified: 2014-07-27
        initials = New String(word.Split(" "c).Select(Function(f) f(0)).ToArray).ToUpper()

Open in new window

 For Each ch As Char In word
            
                If Not Char.IsWhiteSpace(ch) Then
                    intCount += 1
               
            End If

Open in new window

I am using function TextChanged, this problem works with a button but when typeing the text when I get to a space I get and error from initials
Index was outside the bounds of the array.
with my above example how can this be fixed.
0
Comment
Question by:sevensnake77
2 Comments
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 40223012
Try this out instead:
initials = String.Join("", word.Split(" ").Select(Function(f) If(f.Length = 0, "", f.Substring(0, 1).ToUpper)).ToArray)

Open in new window

0
 
LVL 9

Author Closing Comment

by:sevensnake77
ID: 40223026
Great, thanks
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question