Solved

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

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

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 46

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB.Net - TypeInitializer Error 25 32
VB.Net WebRequest Code from JSON curl 7 50
VB.NET 2008 Publish Error 2 34
VB.Net - String Manipulation Scenario 2 25
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

838 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