Solved

Index was outside the bounds of the array. TextChanged

Posted on 2014-07-27
2
123 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 86

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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
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…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

737 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