Solved

How can i count the Alphabet  using vb.net

Posted on 2009-05-17
4
734 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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Suggested Solutions

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
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…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

733 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