Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How can i count the Alphabet  using vb.net

Posted on 2009-05-17
4
Medium Priority
?
739 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 2000 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

721 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