?
Solved

Decimal Validaton

Posted on 2003-03-25
9
Medium Priority
?
242 Views
Last Modified: 2010-04-17
hi there,

can anyone help me with validation process. i want to check whether a value entered ina text field is not decimal. if it is decimal, then a msb prompts for a message else if the value entered is int.. message ok.

thanks
yogesh
0
Comment
Question by:yogeshk
[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
  • 2
  • 2
  • +2
9 Comments
 

Author Comment

by:yogeshk
ID: 8207413
urgent please
0
 

Author Comment

by:yogeshk
ID: 8207418
that site is really great
0
 
LVL 44

Accepted Solution

by:
Arthur_Wood earned 80 total points
ID: 8207626
you want to determine if the value entered in a TextBox is a NUMBERwith a deciml point?

try this:

Private Sub txtValue_Validate()
   if isNumeric(txtValue.Text) then
      if instr(txtValue.Text,".")>0 then
            MsgBox "Value IS a DECIMAL value", vbokonly
      else
            MsgBox Value is an INTEGER", vbOkOnly
      end if
   Else
     MsgBox "Value is NOT a valid Number", vbokonly
   end if
End Sub

that should test properly...

Arthur Wood
0
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 8207628
oh yeah, that code is Visual Basic...you did not mention what programming language you needed.

AW
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 8207960
Java:

String str = myTextField.getText () ;
int len = str.length () ;

for ( int i = 0 ; i < len ; i ++ )
  if ( ! Character.isDigit ( str.charAt ( i ) ) && str.charAt ( i ) != '.' )
  {
    System.out.println ( "\n Invalid number. "  ) ;
    break ;

  } // end if, for


Mayank.
0
 

Expert Comment

by:raseniero
ID: 8256009
try this one!

if isnumeric(txtdecimal.text) then
   msgbox "Valid Decimal"
else
   msgbox "Invalid Decimal"
end if
0
 

Expert Comment

by:CleanupPing
ID: 9446785
yogeshk:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 9451891
Well, we still don't know which programming language he was looking for! Else, split points between mayankeagle and Arthur_Wood.
0

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
Simple Linear Regression
Starting up a Project
Suggested Courses

764 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