?
Solved

Validate textbox input is a multiple of 20

Posted on 2006-05-31
5
Medium Priority
?
317 Views
Last Modified: 2010-04-17
I have a text box in an app that has to contain a value that is a multiple of 20.. basically have to divide by 20 and ensure that the remainder is a whole number - help with this is appreciated.
0
Comment
Question by:egdigital
5 Comments
 
LVL 2

Assisted Solution

by:jonshern
jonshern earned 400 total points
ID: 16803823
Server side or client side?

Use the mod operator  (%)

if((int)txtValue % 20 == 0)
{
        //Value is a multiple of 20
}
else
{
      // Value is not a multiple of 20
}
0
 
LVL 24

Expert Comment

by:fridom
ID: 16805783
Do you feel that (int) txtValue is an approach that can work? You use of % suggest you are talking about C and I can assure that your code does not work that way.

To get the content of a the text field. that can be done with either
GetDlgItemText or as an int with GetDltItemInt.

You code does the following it casts a char* to some int and divides that after that. Surely not what the OP wanted.

Friedrich
0
 
LVL 2

Expert Comment

by:jonshern
ID: 16807271
What language is this being written in?
That way I can provide a more language specific answer.

Thanks
0
 

Author Comment

by:egdigital
ID: 16811357
Its being written in vb
0
 
LVL 4

Accepted Solution

by:
programmer1024 earned 600 total points
ID: 16821157

if val(txtValue.text) Mod 20 = 0 then
       'Value is a multiple of 20
else
      'Value is not a multiple of 20
end if
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

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

In this post we will learn different types of Android Layout and some basics of an Android App.
If you are a mobile app developer and especially develop hybrid mobile apps then these 4 mistakes you must avoid for hybrid app development to be the more genuine app developer.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Starting up a Project

864 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