473,396 Members | 1,990 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Even and odd numbers

Hi i am trying to learn VB and i'm practising "if statements" what i would really like to do is use one if statement for if the shirts value is odd and another for if the shirts value is even, can anyone help.
Thanks

Angel

Expand|Select|Wrap|Line Numbers
  1.  If shirts = 1 Then
  2.             reg = 12
  3.             markdown = 9
  4.             savings = 3
  5.         Else
  6.             If shirts >= 2 And shirts < 25 Then
  7.                 reg = 10 * shirts
  8.                 markdown = reg * 0.75
  9.                 savings = reg * 0.25
  10.             Else
  11.                 If shirts >= 25 Then
  12.                     MessageBox.Show("Please contact the manager for a special price", "Bulk Order")
  13.                 End If
  14.             End If
  15.         End If
  16.  
Mar 13 '10 #1
2 2696
kadghar
1,295 Expert 1GB
Im not sure if there's a function that does that, but while you find it, you can use MOD, here is an example:

Expand|Select|Wrap|Line Numbers
  1. if shirts mod 2 = 0 then
  2.     'do whatever you do with evens
  3. else
  4.     'do what you do with odds
  5. end if
HTH
Mar 13 '10 #2
That is fantastic, thank you!
Mar 13 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

14
by: Debbie Lucier | last post by:
How would I generate a even random number each time? I can generate a random number each time but not an even one? Here is the code I use for the random number from 1-100. <script...
2
by: Lance Hoffmeyer | last post by:
So, I have using the following to grab numbers from MS Word. I discovered that that there is a "special" rule being used for rounding. If a ??.5 is even the number is to rounded down (20.5 = 20)...
1
sonic
by: sonic | last post by:
During input validation, how would one decipher between even and odd numbers? I have to write a program that allows an individual to select numbers between 2-14, excluding odds. Here is a snippet...
17
by: Ron | last post by:
I want to write a program that will accept a number in a textbox for example 23578 and then in a label will display the sum of the odd and even number like this... the textbox containsthe number...
6
by: devoreband | last post by:
hey i wrote all my code but i need to print out only the even numbers so is there any predefined function i can use or what can structure i should be following? ........ 16 for(int r = 0;...
2
by: cmeekeen | last post by:
How do I square the numbers in the even rows? I have generated 100 integer random numbers in the range of 1 to 100 in array x(10,10). Private Sub Form_Activate() Const row As Integer = 10 Const...
25
by: melsayid | last post by:
The program always shows that the input is odd. int main () { int n, d; printf ("Enter a Number: "); scanf ("%d", &n); d=1; if (d==n)
30
by: bdsatish | last post by:
The built-in function round( ) will always "round up", that is 1.5 is rounded to 2.0 and 2.5 is rounded to 3.0. If I want to round to the nearest even, that is my_round(1.5) = 2 # As...
18
by: =?ISO-8859-1?Q?Ney_Andr=E9_de_Mello_Zunino?= | last post by:
Hello. It seems a year is all it takes for one's proficiency in C++ to become too rusty. Professionally, I've been away from the language (and from programming in general), but I still preserve...
2
by: colordrm88 | last post by:
Here is what I am supposed to do...Write a C++ program that asks for 10 numbers and prints the sum of only the even numbers. I also have to use an if statement and a while loop. Please please...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.