473,748 Members | 2,276 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How can I check if a letter in a string is upper case or lower case ?

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,142 0,1402,1411.5
NQ,z2003,11/10/2003,223801,260 154
NQ,H2004,11/11/2003,1416.5,142 2.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.
Apr 4 '07 #1
14 43840
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,1 1/11/2003,1416.5,142 0,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******** *******@TK2MSFT NGP06.phx.gbl.. .
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,142 0,1402,1411.5
NQ,z2003,11/10/2003,223801,260 154
NQ,H2004,11/11/2003,1416.5,142 2.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.


Apr 4 '07 #2
>In VB.NET 2005 can I check if a letter in a string is upper case or lower
case ?
If Char.IsUpper(yo urString, 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.
Apr 4 '07 #3
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.nosp amwrote in message
news:Ok******** ******@TK2MSFTN GP02.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,1 1/11/2003,1416.5,142 0,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******** *******@TK2MSFT NGP06.phx.gbl.. .
>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,142 0,1402,1411.5
NQ,z2003,11/10/2003,223801,260 154
NQ,H2004,11/11/2003,1416.5,142 2.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.



Apr 4 '07 #4
On Apr 4, 2:52 pm, "fniles" <fni...@pfmail. comwrote:
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,142 0,1402,1411.5
NQ,z2003,11/10/2003,223801,260 154
NQ,H2004,11/11/2003,1416.5,142 2.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.
You could use the .ToUpper and the .ToLower methods.

if val = val.ToUpper then ' string is upper case

if val = val.ToLower then ' string is lower case

Apr 4 '07 #5
On Apr 4, 4:00 pm, z...@constructi on-imaging.com wrote:
On Apr 4, 2:52 pm, "fniles" <fni...@pfmail. comwrote:
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,142 0,1402,1411.5
NQ,z2003,11/10/2003,223801,260 154
NQ,H2004,11/11/2003,1416.5,142 2.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.

You could use the .ToUpper and the .ToLower methods.

if val = val.ToUpper then ' string is upper case

if val = val.ToLower then ' string is lower case
And in your specific case, use the .SubString method to pick off the
character you need to check,

if val.substring(3 , 1) = val.substring(3 , 1).tolower then ' is lower
case

Apr 4 '07 #6
Hello fniles,

You can check with the following routine:

Private Function IsUpper(ByVal Value As String) As Boolean
Return (Value = Value.ToUpper)
End Sub

Just give it the letter and it will tell you...

If IsUpper(Strings .Mid(MyLine,4,1 )) = True Then
MsgBox ("Is UpperCase")
Else
MsgBox ("Is LowerCase")
End If

Best regards,

Martin

fniles wrote:
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,142 0,1402,1411.5
NQ,z2003,11/10/2003,223801,260 154
NQ,H2004,11/11/2003,1416.5,142 2.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.

Apr 4 '07 #7
Just to re-work some of your code to be more .NET Friendly :):

Private Function IsUpper(ByVal Value As String) As Boolean
Return Value = Value.ToUpper
End Sub

Dim theString = "NQ,Z2003,1 1/11/2003,1416.5,142 0,1402,1411.5"
If IsUpper(theStri ng.subString(3, 1)) Then
MessageBox.Show ("Is UpperCase")
Else
MessageBox.Show ("Is LowerCase")
End If
"Martin H." <hk***@gmx.netw rote in message
news:46******** *************** @news.freenet.d e...
Hello fniles,

You can check with the following routine:

Private Function IsUpper(ByVal Value As String) As Boolean
Return (Value = Value.ToUpper)
End Sub

Just give it the letter and it will tell you...

If IsUpper(Strings .Mid(MyLine,4,1 )) = True Then
MsgBox ("Is UpperCase")
Else
MsgBox ("Is LowerCase")
End If

Best regards,

Martin

fniles wrote:
>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,142 0,1402,1411.5
NQ,z2003,11/10/2003,223801,260 154
NQ,H2004,11/11/2003,1416.5,142 2.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.
Apr 4 '07 #8
Nice code Martin,

The Mid is one of the old VB commands I have always prefered, I missed it in
other languages.

Cor

Hello fniles,

You can check with the following routine:

Private Function IsUpper(ByVal Value As String) As Boolean
Return (Value = Value.ToUpper)
End Sub

Just give it the letter and it will tell you...

If IsUpper(Strings .Mid(MyLine,4,1 )) = True Then
MsgBox ("Is UpperCase")
Else
MsgBox ("Is LowerCase")
End If

Best regards,

Martin

fniles wrote:
>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,142 0,1402,1411.5
NQ,z2003,11/10/2003,223801,260 154
NQ,H2004,11/11/2003,1416.5,142 2.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.
Apr 5 '07 #9
Thank you, all.
I can also use the following:
bMatch = sMonthYear.Subs tring(0, 1) Like "[A-Z]"
If bMatch Then
'upper case
else
'lower case
end if

"Martin H." <hk***@gmx.netw rote in message
news:46******** *************** @news.freenet.d e...
Hello fniles,

You can check with the following routine:

Private Function IsUpper(ByVal Value As String) As Boolean
Return (Value = Value.ToUpper)
End Sub

Just give it the letter and it will tell you...

If IsUpper(Strings .Mid(MyLine,4,1 )) = True Then
MsgBox ("Is UpperCase")
Else
MsgBox ("Is LowerCase")
End If

Best regards,

Martin

fniles wrote:
>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,142 0,1402,1411.5
NQ,z2003,11/10/2003,223801,260 154
NQ,H2004,11/11/2003,1416.5,142 2.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.
Apr 5 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
8690
by: semovrs | last post by:
Hello, everyone! I would appreciate any input or advice on the following quite simple issue: If I search through a file list using grep -E '.*$' it will not pull files ending in JPG and files ending in png which is fine. However, I have some files ending in jpg (note - lower case) and it will not display them either. Why is that? Am I doing something wrong here and if so - what? It obviously is a regexp issue and not a grep issue because...
10
2937
by: David | last post by:
What can I do to accept either uppercase or lower case " y or n" in the program below.? any help will be appreciated #include <iostream> using namespace std; //class definigtion class Pizza {
22
6443
by: DJ | last post by:
Can someone tell me the library call that converts strings to lower case or retrns a new string that is lower case of the original, thanks im using <string> David
9
2794
by: B Williams | last post by:
I have written some code that will take in a string and print out the reverse, but I also want it to check for upper and lower case and swap them. Will someone assist me? include <iostream> using std::cout; using std::cin; using std::endl; #include <string>
4
5150
by: silversnake | last post by:
Hi , dose one know the code for checking through a string for upper or lower case char's and reverse them of find ? thanks
5
3084
by: cfmx2008 | last post by:
Hi Guys, I hope you could help me to solve this problem. Here it is: I have a huge table of data. Some data are Lower case and some are upper case. these data could be changed by agents, But I want to keep the case. For example: if data is Lower case and it changed to upper case at the time of change it should be lower case again. I know sounds terrible, but this is the problem. any hints will be appreciated. thanks
0
8832
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9558
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9331
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9253
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8250
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6077
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4608
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2791
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2216
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.