CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2008
    Posts
    24

    Question need help with validation..

    i wont to includ a validation for these...but i dont no how !!?
    Code:
    if (x==1)
    {
    inp =JOptionpane.showInputDialoge("Enter Number of miles')
    int y= Integer.parseInt(inp);
    double miles=c.KmToMiles(y);
    JOptionpane.showmessageDialog(null,"Miles="+miles);
    
    }
    
    
    if (x==2)
    {
    inp =JOptionpane.showInputDialoge("Enter Number of km ")
    int y= Integer.parseInt(inp);
    double km=c.MilesToKm(y);
    JOptionpane.showmessageDialog(null,"km="+km);
    
    }
    how can i do it ..!!!!!!???
    Last edited by nadykool; April 25th, 2008 at 05:14 PM. Reason: speling

  2. #2
    Join Date
    Apr 2007
    Posts
    442

    Re: need help with validation..

    Code you posted does not compile. Send something that does compile, makes it well easier to see where you actually have issues. Meanwhile, check this tutorial, seems to be right down your alley.

    http://www.leepoint.net/notes-java/G...ptionpane.html

  3. #3
    Join Date
    Jun 2006
    Posts
    31

    Re: need help with validation..

    Otherwise if you are trying to make sure you have a valid number, take a look at Integer.parseInt(String) and make note that it can throw NumberFormatException. To handle that, try taking a look at handling exceptions. I am not sure what you were asking however.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured