PC Review Forums Newsgroups Microsoft DotNet Microsoft VB .NET simple UCase program??

Reply

simple UCase program??

 
Thread Tools Rate Thread
Old 29-03-2008, 11:45 PM   #1
Jason
Guest
 
Posts: n/a
Default simple UCase program??


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
  Reply With Quote
Old 30-03-2008, 12:14 AM   #2
Nathan Sokalski
Guest
 
Posts: n/a
Default Re: simple UCase program??

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.
--
Nathan Sokalski
njsokalski@hotmail.com
http://www.nathansokalski.com/

"Jason" <paul814@excite.com> wrote in message
news:9a618680-bd22-409a-9328-4ef8ddda4d7b@l42g2000hsc.googlegroups.com...
> 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



  Reply With Quote
Old 30-03-2008, 06:22 AM   #3
Spam Catcher
Guest
 
Posts: n/a
Default Re: simple UCase program??

Jason <paul814@excite.com> wrote in news:9a618680-bd22-409a-9328-
4ef8ddda4d7b@l42g2000hsc.googlegroups.com:

> 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.

--
spamhoneypot@rogers.com (Do not e-mail)
  Reply With Quote
Old 30-03-2008, 06:33 AM   #4
Bill McCarthy
Guest
 
Posts: n/a
Default Re: simple UCase program??

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


"Nathan Sokalski" <njsokalski@hotmail.com> wrote in message
news:Os1C3rfkIHA.5260@TK2MSFTNGP03.phx.gbl...
> 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.
> --
> Nathan Sokalski
> njsokalski@hotmail.com
> http://www.nathansokalski.com/
>
> "Jason" <paul814@excite.com> wrote in message
> news:9a618680-bd22-409a-9328-4ef8ddda4d7b@l42g2000hsc.googlegroups.com...
>> 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

>
>


  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off