468,146 Members | 1,512 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,146 developers. It's quick & easy.

How to Check if character is Uppercase

This is my code so far::

Expand|Select|Wrap|Line Numbers
  1. Dim Array(7) As Char
  2.         Dim myman As String = TextBox1.Text
  3.         Dim capcount As Integer = 0
  4.  
  5.         Array = myman.ToCharArray
  6.  
  7.  
  8.         If TextBox1.Text = TextBox2.Text Then
  9.             If TextBox1.Text = "" Then
  10.                 MessageBox.Show("mhm")
  11.                 Stop
  12.             End If
  13.             For i = 0 To 7
  14.                 If Char.IsUpper(Array, i) Then
  15.                     capcount = capcount + 1
  16.                 End If
Jan 28 '19 #1
3 3101
SioSio
238 128KB
Next for For statement and
End if for If then is missing
Index is outside array bounds
Expand|Select|Wrap|Line Numbers
  1. Dim Array(7) As Char
  2. Dim myman As String = TextBox1.Text
  3. Dim capcount As Integer = 0
  4. Array = myman.ToCharArray
  5. If TextBox1.Text = TextBox2.Text Then
  6. If TextBox1.Text = "" Then
  7. MessageBox.Show("mhm")
  8. Stop
  9. End If
  10. For Each c As Char In Array
  11. If Char.IsUpper(c) Then
  12. capcount = capcount + 1
  13. End If
  14. Next
  15. End if
  16.  
Dec 19 '19 #2
cactusdata
164 Expert 128KB
Compare the full string in one line:

Expand|Select|Wrap|Line Numbers
  1. Dim Myman As String
  2.  
  3. 'Myman = "lowercase"
  4. Myman = "MixedCase"
  5. 'Myman = "UPPERCASE"
  6.  
  7. Dim IsUpper As Boolean
  8.  
  9. IsUpper = Myman.ToUpper().Equals(Myman)
  10.  
  11. Console.WriteLine(IsUpper.ToString())
Dec 19 '19 #3
AjayGohil
84 64KB
hi try this for checked uppercase
Expand|Select|Wrap|Line Numbers
  1.    string Mystring = "SimpleWordforExAmple";
  2.         char[] chars;
  3.         char ch;
  4.         int length = Mystring.Length;
  5.         int cnt;
  6.         int totalcntupper = 0;
  7.  
  8.         chars = Mystring.ToCharArray(0, length);
  9.  
  10.         Console.WriteLine("Sample words with capital letters : {0} ", Mystring);
  11.         for (cnt = 0; cnt < length;cnt ++)
  12.         {
  13.             ch = chars[cnt];
  14.  
  15.  
  16.             if (char.IsUpper(ch))
  17.             {
  18.                 Console.WriteLine("Capital letter : #{0}", ch);
  19.                 totalcntupper++;
  20.  
  21.             }
  22.  
  23.  
  24.         }
  25.  
  26.         Console.WriteLine("Count of capital letter(s) : # {0}", totalcntupper);
  27.         Console.ReadLine();
Dec 26 '19 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

7 posts views Thread by Al Kolff | last post: by
6 posts views Thread by Dave Hague | last post: by
6 posts views Thread by Mika M | last post: by
2 posts views Thread by Andy Fish | last post: by
3 posts views Thread by zalina | last post: by
1 post views Thread by gcdp | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.