Solved

How to determine how many ODD and EVEN digits are in a number using VB6?

Posted on 2016-07-17
3
60 Views
Last Modified: 2016-07-18
How can one use VB6 to determine how many ODD and how many EVEN digits there are in a number?
Example----Label1 has the following number on it:
174638891  

..... 5 of the digits are ODD .... 4 of the digits are EVEN

Thanks.
0
Comment
Question by:jazjef
  • 2
3 Comments
 
LVL 45

Accepted Solution

by:
Martin Liss earned 500 total points
Comment Utility
Dim intCount As Integer
Dim intIndex As Integer

For intIndex = 1 To Len(Label1.Caption)
    If Mid(Label1.Caption, intIndex, 1) Mod 2 = 0 Then
        intCount = intCount + 1
    End If
Next
MsgBox "There are " & intCount & " even numbers"
MsgBox "There are " & Len(Label1.Caption) - intCount & " odd numbers"

Open in new window

0
 
LVL 4

Author Closing Comment

by:jazjef
Comment Utility
Thanks Martin .... works great.
0
 
LVL 45

Expert Comment

by:Martin Liss
Comment Utility
You're welcome and I'm glad I was able to help.

In my profile you'll find links to some articles I've written that may interest you.

Marty - Microsoft MVP 2009 to 2016
              Experts Exchange MVE 2015
              Experts Exchange Top Expert Visual Basic Classic 2012 to 2015
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now