Solved

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

Posted on 2016-07-17
3
98 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
[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
  • 2
3 Comments
 
LVL 47

Accepted Solution

by:
Martin Liss earned 500 total points
ID: 41716305
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
ID: 41717855
Thanks Martin .... works great.
0
 
LVL 47

Expert Comment

by:Martin Liss
ID: 41717886
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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

707 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