simple UCase program??

  • Thread starter Thread starter Jason
  • Start date Start date
J

Jason

Can someoen show me a simple way to do this?

I want to either read a file or copy and paste text into an Rich text
textbox on the form. I then want to hit a button and the program will
run through the code and in a label display all of the CAPITAL letters
in that document.

so if I had this document.

i think That Some of The People here do great things.

it would show me:
TSTP

is there a show ucase stament or something, thanks for any help
 
No, there is not a built-in function to do that, but you may be interested
in the following functions:

Char.IsUpper()
Char.IsLower()

If you use the ToCharArray() method of the String class to get an array of
Chars, you can then use a loop to check each one, sort of like this:

Dim original As String
Dim capitals As String = ""
Dim originalchars() As Char = original.ToCharArray()
For Each x As Char In originalchars
If Char.IsUpper(x) Then capitals = String.Concat(capitals, x)
Next

You will need to assign your original string a value in the declaration (or
sometime before calling the ToCharArray() method). Depending on the length
of your original string, you may want to use the System.Text.StringBuilder
class for the capitals variable for the sake of efficiency, but that is your
decision. Hopefully this helps.
 
i think That Some of The People here do great things.

it would show me:
TSTP

You can either use Regular Expressions or String Parsing to do this.

A simple RegEx to find uppercase characters would be [A-Z]. Then you can
loop through all the matches and display it to the user.
 
Or you can use LINQ syntax in VB9 (2008) to make this :

Dim capitals As String = (From c In original Where Char.IsUpper(c)).ToArray
 
Back
Top