Solved

Help with Message Box

Posted on 2000-02-20
3
155 Views
Last Modified: 2010-05-02
I don't think that this is working the way it should and it will let me put text in the first box and after I enter a number in the second box it will have a message box come up and say enetr numbers only.  Is this correct or shouldn't it do it when I enetr text into (txtInputOne.Text) or is this correct???
Here is the code

     If IsNumeric(txtInputOne.Text) Then
           optAdd.Value = True Or optSubtract.Value = True Or optMultiply.Value           = True Or optDivide.Value = True
       Else
            MsgBox "Please Enter Numbers Only", vbOKOnly, "Invaild Data             Entered"
            txtInputOne.SetFocus
        End If
0
Comment
Question by:earth2d
3 Comments
 
LVL 3

Accepted Solution

by:
fibdev earned 20 total points
ID: 2540375
Try it this way:

Dim numOnly As String
numOnly = txtInputOne.Text

If IsNumeric(numOnly) = True Then
  optAdd.Value = True Or _
  optSubtract.Value = True Or _
  optMultiply.Value = True Or _
  optDivide.Value = True
Else
  MsgBox "Please Enter Numbers Only", vbOKOnly, "Invalid Data Entered"
  txtInputOne.SetFocus
End If

From what I can make of your question, that looks right (The message box part anyway.)
0
 
LVL 14

Expert Comment

by:mcrider
ID: 2540381
It runs fine on my system.  I commented out the line after the if, but the rest works...
0
 

Author Comment

by:earth2d
ID: 2540603
Thanks it does work either way.  My way or your way.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

762 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

18 Experts available now in Live!

Get 1:1 Help Now