Solved

How can i count the Alphabet  using vb.net

Posted on 2009-05-17
4
737 Views
Last Modified: 2012-06-27
example:

dim xvar as string
xvar="abc0001"
In this variable 'xvar' how can i count the number of alphbet
 
0
Comment
Question by:mseit
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 53

Expert Comment

by:Dhaest
ID: 24409351
What do you mean with the coutn of alphabet ?
What is the desired output for given example ?
0
 
LVL 39

Accepted Solution

by:
Pratima Pharande earned 500 total points
ID: 24409413
try this

In intLoopLetter variable you get the number of alphabets
       Dim xvar As String
        xvar = "abc000123a"
 
        Dim current As Integer
        Dim intLoopStrText, intLoopLetter As Integer
        xvar = xvar.ToUpper
        intLoopStrText = 0
        intLoopLetter = 0
        While (intLoopStrText < xvar.Length)
            current = Asc(xvar.Substring(intLoopStrText, 1))
            If current >= 65 And current <= 90 Then
                intLoopLetter = intLoopLetter + 1
            End If
            intLoopStrText += 1
        End While

Open in new window

0
 
LVL 18

Expert Comment

by:philipjonathan
ID: 24409427
mseit, are you trying to count the number of alphabets in the given string?
If so you can try:

Dim count As Integer = 0
For Each c As Char in xvar
    If Char.IsLetter(c) Then count += 1
Next

You get the result in variable count
0
 

Author Closing Comment

by:mseit
ID: 31582492
Excellent Solution
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question