By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,327 Members | 1,096 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,327 IT Pros & Developers. It's quick & easy.

Character case level question

P: n/a
Hi!

How can I check which chars in String are UpperCase chars?

I mean for example string "aAbBc" has second and fourth character uppercase
characters, so I want to get this information somehow. I'm using VB .NET
2003, but understand C# also quite well.

--
Thanks in advance!

Mika
Nov 21 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a

like this :

Dim c As Char

For Each c In TextBox1.Text
If UCase(c) = c Then
MsgBox(c & " is uppercase")
Else
MsgBox(c & " is lowercase")
End If
Next

then i suppose instead of "MsgBox(c & " is uppercase")"
you would fill an array of chars that are returned as UCase
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 21 '05 #2

P: n/a
Dim str As String = "aBc"
Dim ch As Char
Dim ContainsUppers As Boolean = False

For Each ch In str.ToCharArray

If ch = Char.ToUpper(ch) Then
ContainsUppers = True
Exit For
End If

Next

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me

Time flies when you don't know what you're doing

"Mika M" <mika.mahonen@nospam_kolumbus.fi> wrote in message
news:Oq**************@TK2MSFTNGP12.phx.gbl...
Hi!

How can I check which chars in String are UpperCase chars?

I mean for example string "aAbBc" has second and fourth character uppercase characters, so I want to get this information somehow. I'm using VB .NET
2003, but understand C# also quite well.

--
Thanks in advance!

Mika

Nov 21 '05 #3

P: n/a
> How can I check which chars in String are UpperCase chars?
Dim strX As String = "aAbBc"

For i As Integer = 0 To strX.Length
If strX.SubString(i,1) = strX.SubString(i,1).ToUpper Then
MessageBox.Show("Uppercase on " + CStr(i) )
End If
Next

--
Pozdrav,
Josip Medved, MCSD
http://www.jmedved.com
Nov 21 '05 #4

P: n/a
Oh! so simple - and I didn't got it by myself :)

Thanks for every reply!
Nov 21 '05 #5

P: n/a
* "Mika M" <mika.mahonen@nospam_kolumbus.fi> scripsit:
How can I check which chars in String are UpperCase chars?

I mean for example string "aAbBc" has second and fourth character uppercase
characters, so I want to get this information somehow. I'm using VB .NET
2003, but understand C# also quite well.


\\\
Dim c As Char
For Each c in "aAbBc"
If Char.IsUpper(c) Then
...
End If
Next c
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #6

P: n/a
Mika,
I would use Char.IsUpper that Herfried identified, the System.Char structure
has a number of shared functions that will check what "kind" of character
that was passed. Such as: IsControl, IsDigit, IsLetter, IsLetterOrDigit,
IsLower, IsNumber, IsPunctuation, IsSeparator, IsSurrogate, IsSymbol,
IsUpper, IsWhiteSpace.

You can also use Char.GetUnicodeCategory for similar information.

Hope this helps
Jay

"Mika M" <mika.mahonen@nospam_kolumbus.fi> wrote in message
news:Oq**************@TK2MSFTNGP12.phx.gbl...
Hi!

How can I check which chars in String are UpperCase chars?

I mean for example string "aAbBc" has second and fourth character uppercase characters, so I want to get this information somehow. I'm using VB .NET
2003, but understand C# also quite well.

--
Thanks in advance!

Mika

Nov 21 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.