-3

Possible Duplicate:
How to remove lowercase on a textbox?

I'm trying to remove the lower case letters on a TextBox..

For example, short alpha code representing the course(e.g., 'BSCS' for 'Bacheclor of Science in Computer Science):

Please help me. Thanks!

Community
  • 1
  • 1
BlackKnights
  • 135
  • 1
  • 9

3 Answers3

3

Use a regular expression:

using System.Text.RegularExpressions;

texbox.Text = Regex.Replace(textbox.Text, "[^A-Z]", "");

Anything you don't want (non-uppercase characters) will be replaced with blank.

pickypg
  • 22,034
  • 5
  • 72
  • 84
1

Use Char.IsUpper.

Marlon
  • 19,924
  • 12
  • 70
  • 101
0

I don't know the actual c# code but I can conceptualize it for you if you're SURE that all acronyms will be properly represented by just the capitals in the given string.

  • blow the string up into an array where each array element is a character
  • convert each element to it's character representation
  • check it against the numeric order of available capital letters
    • if it's a capital letter, add it to a variable for use later

Pseudo-code:

$charArray = $string.split("")
foreach ($item in $charArray) {
   if ([int]$item > 64 && [int]$item < 91) {
      $acronym += [char]$item
   }
}

Edit: Here is the character reference chart: http://msdn.microsoft.com/en-us/library/60ecse8t(VS.80).aspx

thepip3r
  • 2,855
  • 6
  • 32
  • 38