Character case level question

  • Thread starter Thread starter Mika M
  • Start date Start date
M

Mika M

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.
 
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
 
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
 
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
 
* "Mika M said:
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
///
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top