Solved

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

Posted on 2016-07-17
3
88 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
which modules are active in VB6 project? 6 52
Generate Numbers in JQuery file 11 72
Need syntax help building hyperlink 2 41
ModalPopup  question 22 38
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
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…

749 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