如何检查字符串中的字母是大写还是小写? [英] How can I check if a letter in a string is upper case or lower case ?

查看:149
本文介绍了如何检查字符串中的字母是大写还是小写?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在VB.NET 2005中,我可以检查字符串中的字母是大写还是更低

大小写?

例如:

我有以下两行:

NQ,Z2003,11 / 11 / 2003,1416.5,1420,1402,1411.5

NQ,z2003,11 / 10/2003 ,223801,260154

NQ,H2004,11 / 11 / 2003,1416.5,1422.5,1406.5,1415

NQ,h2004,11 / 10 / 2003,56,1191


注意第一行有大写Z(Z2003),第二行有小写z

(z2003)。

之后我读了这行,我想知道行中的第二项

(在NQ之后)是否有小写字母或大写字母。我怎么能这样做?


谢谢。

In VB.NET 2005 can I check if a letter in a string is upper case or lower
case ?
For example:
I have the following 2 lines:
NQ,Z2003,11/11/2003,1416.5,1420,1402,1411.5
NQ,z2003,11/10/2003,223801,260154
NQ,H2004,11/11/2003,1416.5,1422.5,1406.5,1415
NQ,h2004,11/10/2003,56,1191

Notice the 1st line has uppercase Z (Z2003) and the 2nd line has lowercase z
(z2003).
After I read the line, I would like to find out if the 2nd item in the line
(after NQ) has small letter or uppercase. How can I do that ?

Thanks.

推荐答案

有很多方法可以做到这一点,但这里有一个简单的,如果你

总是知道哪个特定的字符。你想检查:


Dim x As String =" NQ,Z2003,11 / 11 / 2003,1416.5,1420,1402,1411.5"

选择案例权利(左(x,4),1)

案例" z"

''做点什么

案例" Z"

''做其他事情

结束选择

" fniles" < fn **** @ pfmail.com在留言中写道

新闻:e7 *************** @ TK2MSFTNGP06.phx.gbl ...
There are a number of ways to do this, but here is a simple one if you
always know which particular char. you want to check:

Dim x As String = "NQ,Z2003,11/11/2003,1416.5,1420,1402,1411.5"
Select Case right(left(x,4),1)
Case "z"
''do something
Case "Z"
''do something else
End Select
"fniles" <fn****@pfmail.comwrote in message
news:e7***************@TK2MSFTNGP06.phx.gbl...

在VB.NET 2005中,我可以检查字符串中的字母是大写还是更低

case?

例如:

我有以下2行:

NQ,Z2003,11 / 11 / 2003,1416.5,1420,1402,1411.5

NQ,z2003,11 / 10 / 2003,223801,260154

NQ,H2004,11 / 11 / 2003,1416.5,1422.5,1406.5,1415

NQ, h2004,11 / 10 / 2003,56,1191


注意第1行有大写Z(Z2003),第2行有小写

z(z2003) 。

读完这行后,我想知道

行中的第二项(NQ之后)是否有小写字母或大写字母。我怎么能这样做?


谢谢。

In VB.NET 2005 can I check if a letter in a string is upper case or lower
case ?
For example:
I have the following 2 lines:
NQ,Z2003,11/11/2003,1416.5,1420,1402,1411.5
NQ,z2003,11/10/2003,223801,260154
NQ,H2004,11/11/2003,1416.5,1422.5,1406.5,1415
NQ,h2004,11/10/2003,56,1191

Notice the 1st line has uppercase Z (Z2003) and the 2nd line has lowercase
z (z2003).
After I read the line, I would like to find out if the 2nd item in the
line (after NQ) has small letter or uppercase. How can I do that ?

Thanks.




>在VB.NET 2005中,我可以检查字符串中的字母是大写还是更低
情况?
>In VB.NET 2005 can I check if a letter in a string is upper case or lower
case ?



如果Char.IsUpper(yourString,charIndex)那么...

Mattias


-

Mattias Sj?gren [C#MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com

请回复到新闻组。

If Char.IsUpper(yourString, charIndex) Then ...
Mattias

--
Mattias Sj?gren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.


谢谢。

但是,它可能是z,它可能是f,g,h,j,k,m ,n,q,u,v,x。

我试图避免为每一个做个案陈述。


" Scott M." < s - *** @ nospam.nospamwrote in message

news:Ok ************** @ TK2MSFTNGP02.phx.gbl ...
Thanks.
But, it could be z, it could be f, g, h, j, k, m,n,q,u,v,x.
I am trying to avoid having to do case statement for each one of them.

"Scott M." <s-***@nospam.nospamwrote in message
news:Ok**************@TK2MSFTNGP02.phx.gbl...

有很多方法可以做到这一点,但如果你这么简单,那么
总是知道哪个特定的字符。你想检查:


Dim x As String =" NQ,Z2003,11 / 11 / 2003,1416.5,1420,1402,1411.5"

选择案例权利(左(x,4),1)

案例" z"

''做点什么

案例" Z"

''做其他事情

结束选择


" fniles" < fn **** @ pfmail.com在留言中写道

新闻:e7 *************** @ TK2MSFTNGP06.phx.gbl ...
There are a number of ways to do this, but here is a simple one if you
always know which particular char. you want to check:

Dim x As String = "NQ,Z2003,11/11/2003,1416.5,1420,1402,1411.5"
Select Case right(left(x,4),1)
Case "z"
''do something
Case "Z"
''do something else
End Select
"fniles" <fn****@pfmail.comwrote in message
news:e7***************@TK2MSFTNGP06.phx.gbl...

>在VB.NET 2005中,我可以检查字符串中的字母是大写还是更低
大小写?
例如: NQ,Z2003,11 / 11 / 2003,1416.5,1420,1402,1411.5
NQ,z2003,11 / 10 / 2003,223801,260154 NQ,H2004,11 / 11 / 2003,1416.5,1422.5,1406.5,1415
NQ,h2004,11 / 10 / 2003,56,1191

注意第1行有大写Z (Z2003)和第二行有
小写z(z2003)。
在我读完这一行后,我想知道
行中的第二项(NQ之后)是否有小写字母或大写字母。我该怎么做?

谢谢。

>In VB.NET 2005 can I check if a letter in a string is upper case or lower
case ?
For example:
I have the following 2 lines:
NQ,Z2003,11/11/2003,1416.5,1420,1402,1411.5
NQ,z2003,11/10/2003,223801,260154
NQ,H2004,11/11/2003,1416.5,1422.5,1406.5,1415
NQ,h2004,11/10/2003,56,1191

Notice the 1st line has uppercase Z (Z2003) and the 2nd line has
lowercase z (z2003).
After I read the line, I would like to find out if the 2nd item in the
line (after NQ) has small letter or uppercase. How can I do that ?

Thanks.




这篇关于如何检查字符串中的字母是大写还是小写?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆