473,325 Members | 2,671 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,325 software developers and data experts.

How to determine if a number is odd or even?

Ron
Hello, I want to write some code to determine if a number entered in
a textbox txtnumber is odd or even. How do I do this?

Then if even I want to add 3 to that number and multiply by 4
Or if odd I want to add 2 to that number and multiply by 5

thanks for any help.

Jan 29 '07 #1
19 15665
Use the MOD function:

dim Num as integer
if cint(textbox1.text) MOD 2 = 0 then
Num = (cint(textbox1.text) + 3) * 4
else Num = (cint(textbox1.text) + 2) * 5
endif

On Jan 29, 4:04 pm, "Ron" <pts4...@yahoo.comwrote:
Hello, I want to write some code to determine if a number entered in
a textbox txtnumber is odd or even. How do I do this?

Then if even I want to add 3 to that number and multiply by 4
Or if odd I want to add 2 to that number and multiply by 5

thanks for any help.
Jan 29 '07 #2
Ron
yea that worked great,

so If I want to keep doing something ubntil the result is 1 and adding
it to a listbox would I do this?
......
num = txtnumber.text
while num <>1

num = (1 + 0 ) / 1
lsttresult.items.add (num)
' AND I want to keep doing the above and adding it to that lisbox
until num = 1
Is that how I would do it?

On Jan 29, 5:11 pm, ge0193...@otc.edu wrote:
Use the MOD function:

dim Num as integer
if cint(textbox1.text) MOD 2 = 0 then
Num = (cint(textbox1.text) + 3) * 4
else Num = (cint(textbox1.text) + 2) * 5
endif

On Jan 29, 4:04 pm, "Ron" <pts4...@yahoo.comwrote:
Hello, I want to write some code to determine if a number entered in
a textbox txtnumber is odd or even. How do I do this?
Then if even I want to add 3 to that number and multiply by 4
Or if odd I want to add 2 to that number and multiply by 5
thanks for any help.- Hide quoted text -- Show quoted text -
Jan 29 '07 #3


On Jan 29, 5:35 pm, "Ron" <pts4...@yahoo.comwrote:
yea that worked great,

so If I want to keep doing something ubntil the result is 1 and adding
it to a listbox would I do this?
.....
num = txtnumber.text
while num <>1

num = (1 + 0 ) / 1
lsttresult.items.add (num)
' AND I want to keep doing the above and adding it to that lisbox
until num = 1
Is that how I would do it?
Oh dear that's confusing... your loop condition states that the loop
will run as long as num is not equal to 1. Then you go and set num to
1 on the very next line.

Jan 29 '07 #4
Ron
hmm your right, so how do you think I can make this work, I want the
loop to keep going until num is 1 but I also want to keep calculating
num and adding its result to the listbox until it is 1
On Jan 29, 5:53 pm, lord.zol...@gmail.com wrote:
On Jan 29, 5:35 pm, "Ron" <pts4...@yahoo.comwrote:
yea that worked great,
so If I want to keep doing something ubntil the result is 1 and adding
it to a listbox would I do this?
.....
num = txtnumber.text
while num <>1
num = (1 + 0 ) / 1
lsttresult.items.add (num)
' AND I want to keep doing the above and adding it to that lisbox
until num = 1
Is that how I would do it?Oh dear that's confusing... your loop condition states that the loop
will run as long as num is not equal to 1. Then you go and set num to
1 on the very next line.
Jan 30 '07 #5
>Hello, I want to write some code to determine if a number entered in
a textbox txtnumber is odd or even. How do I do this?

Then if even I want to add 3 to that number and multiply by 4
Or if odd I want to add 2 to that number and multiply by 5

Homework?
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Jan 30 '07 #6
Probably. It's the third time it's come up in the dotnet newsgroups in the
past week. It's like an epidemic. ;-)

Robin S.
-----------------------------------------
"Mattias Sjögren" <ma********************@mvps.orgwrote in message
news:ub****************@TK2MSFTNGP05.phx.gbl...
>
>>Hello, I want to write some code to determine if a number entered in
a textbox txtnumber is odd or even. How do I do this?

Then if even I want to add 3 to that number and multiply by 4
Or if odd I want to add 2 to that number and multiply by 5


Homework?
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Jan 30 '07 #7
You know, colleges should really add a course titled "Looking at the
Documentation 101" or even "Searching Google 101." Maybe then these
guys would quit asking us homework questions...

Thanks,

Seth Rowe
On Jan 30, 2:02 am, "RobinS" <Rob...@NoSpam.yah.nonewrote:
Probably. It's the third time it's come up in the dotnet newsgroups in the
past week. It's like an epidemic. ;-)

Robin S.
-----------------------------------------"Mattias Sjögren" <mattias.dont.want.s...@mvps.orgwrote in messagenews:ub****************@TK2MSFTNGP05.phx.gb l...
>Hello, I want to write some code to determine if a number entered in
a textbox txtnumber is odd or even. How do I do this?
>Then if even I want to add 3 to that number and multiply by 4
Or if odd I want to add 2 to that number and multiply by 5
Homework?
Mattias
--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/|http://www.dotnetinterop.com
Please reply only to the newsgroup.
Jan 30 '07 #8


On Jan 30, 6:54 am, "rowe_newsgroups" <rowe_em...@yahoo.comwrote:
You know, colleges should really add a course titled "Looking at the
Documentation 101" or even "Searching Google 101." Maybe then these
guys would quit asking us homework questions...

Thanks,

Seth Rowe
....or "disguising homework assignments as real-world problems". ;) :P

Jan 30 '07 #9
I agree about the documentation but when unfortunately for some of us
Google did not exsits. You guys do not know how good you have it

I remember back when I was a kid I had to walk to school ... in the
snow ... ten miles .... up hill .... both ways .........

On 30 Jan 2007 03:54:02 -0800, "rowe_newsgroups"
<ro********@yahoo.comwrote:
>You know, colleges should really add a course titled "Looking at the
Documentation 101" or even "Searching Google 101." Maybe then these
guys would quit asking us homework questions...

Thanks,

Seth Rowe
On Jan 30, 2:02 am, "RobinS" <Rob...@NoSpam.yah.nonewrote:
>Probably. It's the third time it's come up in the dotnet newsgroups in the
past week. It's like an epidemic. ;-)

Robin S.
-----------------------------------------"Mattias Sjögren" <mattias.dont.want.s...@mvps.orgwrote in messagenews:ub****************@TK2MSFTNGP05.phx.gb l...
>>Hello, I want to write some code to determine if a number entered in
a textbox txtnumber is odd or even. How do I do this?
>>Then if even I want to add 3 to that number and multiply by 4
Or if odd I want to add 2 to that number and multiply by 5
Homework?
Mattias
--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/|http://www.dotnetinterop.com
Please reply only to the newsgroup.
Jan 30 '07 #10


On Jan 30, 12:57 pm, SomeGrayHa...@gmail.com wrote:
I agree about the documentation but when unfortunately for some of us
Google did not exsits. You guys do not know how good you have it

I remember back when I was a kid I had to walk to school ... in the
snow ... ten miles .... up hill .... both ways .........
You're lucky you had snow! When *I* was young, we only had ice falling
out of the sky (snow had not yet been invented), and the ice pellets
were the size of grapefruits!

Jan 30 '07 #11
They will quit asking when we stop helpign the Indians (natives of
India) learn.
They have a different mentality. If you know it, you should help
them.

FORGET IT.

Enough of our jobs are going there as it is.

As for those non-Indians, they are just too lazy to find it for
themselves.

On Jan 30, 12:23 pm, lord.zol...@gmail.com wrote:
On Jan 30, 12:57 pm, SomeGrayHa...@gmail.com wrote:
I agree about the documentation but when unfortunately for some of us
Google did not exsits. You guys do not know how good you have it
I remember back when I was a kid I had to walk to school ... in the
snow ... ten miles .... up hill .... both ways .........You're lucky you had snow! When *I* was young, we only had ice falling
out of the sky (snow had not yet been invented), and the ice pellets
were the size of grapefruits!
Jan 30 '07 #12
raibeart wrote:
They will quit asking when we stop helpign the Indians (natives of
India) learn.
They have a different mentality. If you know it, you should help
them.

FORGET IT.

Enough of our jobs are going there as it is.

As for those non-Indians, they are just too lazy to find it for
themselves.
Keep in mind that it's not just north-americans that answer questions,
and it's not just non-north-americans the ones who ask then...

Regards,

Branco.

Jan 30 '07 #13
Oh, yeah? *I* used punchcards to write software! Oooooooooooh. (I wonder
if anybody will get that.)

Robin S.
--------------------------------
<lo*********@gmail.comwrote in message
news:11*********************@h3g2000cwc.googlegrou ps.com...
>

On Jan 30, 12:57 pm, SomeGrayHa...@gmail.com wrote:
>I agree about the documentation but when unfortunately for some of us
Google did not exsits. You guys do not know how good you have it

I remember back when I was a kid I had to walk to school ... in the
snow ... ten miles .... up hill .... both ways .........

You're lucky you had snow! When *I* was young, we only had ice falling
out of the sky (snow had not yet been invented), and the ice pellets
were the size of grapefruits!

Jan 31 '07 #14
Well, since we're comparing gray hairs here, of which I have none left to
pull out.....

MY first computer had only four thick wires with 9 circular sliding
components per wire. :)

Bruce

"RobinS" <Ro****@NoSpam.yah.nonewrote in message
news:A8******************************@comcast.com. ..
Oh, yeah? *I* used punchcards to write software! Oooooooooooh. (I wonder
if anybody will get that.)

Robin S.
--------------------------------
<lo*********@gmail.comwrote in message
news:11*********************@h3g2000cwc.googlegrou ps.com...
>>

On Jan 30, 12:57 pm, SomeGrayHa...@gmail.com wrote:
>>I agree about the documentation but when unfortunately for some of us
Google did not exsits. You guys do not know how good you have it

I remember back when I was a kid I had to walk to school ... in the
snow ... ten miles .... up hill .... both ways .........

You're lucky you had snow! When *I* was young, we only had ice falling
out of the sky (snow had not yet been invented), and the ice pellets
were the size of grapefruits!


Feb 1 '07 #15
*I* used a slide rule. :-O

Robin S.
-----------------------
"Bruce W. Darby" <kr******@atcomcast.netwrote in message
news:ip******************************@comcast.com. ..
Well, since we're comparing gray hairs here, of which I have none left to
pull out.....

MY first computer had only four thick wires with 9 circular sliding
components per wire. :)

Bruce

"RobinS" <Ro****@NoSpam.yah.nonewrote in message
news:A8******************************@comcast.com. ..
>Oh, yeah? *I* used punchcards to write software! Oooooooooooh. (I
wonder if anybody will get that.)

Robin S.
--------------------------------
<lo*********@gmail.comwrote in message
news:11*********************@h3g2000cwc.googlegro ups.com...
>>>

On Jan 30, 12:57 pm, SomeGrayHa...@gmail.com wrote:
I agree about the documentation but when unfortunately for some of us
Google did not exsits. You guys do not know how good you have it

I remember back when I was a kid I had to walk to school ... in the
snow ... ten miles .... up hill .... both ways .........
You're lucky you had snow! When *I* was young, we only had ice falling
out of the sky (snow had not yet been invented), and the ice pellets
were the size of grapefruits!



Feb 1 '07 #16
Not only did I use punch cards, but one time going up to the window to give
my stack of cards to the operator, I dropped the cards! Imagine having to
put them back in the right order? Nightmare!

I wonder if any of the IBM 029 card punch machines still exist?
"RobinS" <Ro****@NoSpam.yah.nonewrote in message
news:A8******************************@comcast.com. ..
Oh, yeah? *I* used punchcards to write software! Oooooooooooh. (I wonder
if anybody will get that.)

Robin S.
--------------------------------
<lo*********@gmail.comwrote in message
news:11*********************@h3g2000cwc.googlegrou ps.com...
>>

On Jan 30, 12:57 pm, SomeGrayHa...@gmail.com wrote:
>>I agree about the documentation but when unfortunately for some of us
Google did not exsits. You guys do not know how good you have it

I remember back when I was a kid I had to walk to school ... in the
snow ... ten miles .... up hill .... both ways .........

You're lucky you had snow! When *I* was young, we only had ice falling
out of the sky (snow had not yet been invented), and the ice pellets
were the size of grapefruits!


Feb 1 '07 #17
When I was working at the Army proving grounds in Yuma, AZ, they were
still using one to process payroll.

The poor maintenance contractor had to maintain the beast.

On Feb 1, 12:54 pm, "Zim Babwe"
<zimba...@doyoureallythinkthisisreal.comwrote:
Not only did I use punch cards, but one time going up to the window to give
my stack of cards to the operator, I dropped the cards! Imagine having to
put them back in the right order? Nightmare!

I wonder if any of the IBM 029 card punch machines still exist?

"RobinS" <Rob...@NoSpam.yah.nonewrote in message

news:A8******************************@comcast.com. ..
Oh, yeah? *I* used punchcards to write software! Oooooooooooh. (I wonder
if anybody will get that.)
Robin S.
--------------------------------
<lord.zol...@gmail.comwrote in message
news:11*********************@h3g2000cwc.googlegrou ps.com...
On Jan 30, 12:57 pm, SomeGrayHa...@gmail.com wrote:
I agree about the documentation but when unfortunately for some of us
Google did not exsits. You guys do not know how good you have it
>I remember back when I was a kid I had to walk to school ... in the
snow ... ten miles .... up hill .... both ways .........
You're lucky you had snow! When *I* was young, we only had ice falling
out of the sky (snow had not yet been invented), and the ice pellets
were the size of grapefruits!- Hide quoted text -

- Show quoted text -

Feb 1 '07 #18
Oh, man, I *hate* when that happens!!

Robin S.
---------------------
"Zim Babwe" <zi******@doyoureallythinkthisisreal.comwrote in message
news:OY**************@TK2MSFTNGP03.phx.gbl...
Not only did I use punch cards, but one time going up to the window to
give my stack of cards to the operator, I dropped the cards! Imagine
having to put them back in the right order? Nightmare!

I wonder if any of the IBM 029 card punch machines still exist?
"RobinS" <Ro****@NoSpam.yah.nonewrote in message
news:A8******************************@comcast.com. ..
>Oh, yeah? *I* used punchcards to write software! Oooooooooooh. (I
wonder if anybody will get that.)

Robin S.
--------------------------------
<lo*********@gmail.comwrote in message
news:11*********************@h3g2000cwc.googlegro ups.com...
>>>

On Jan 30, 12:57 pm, SomeGrayHa...@gmail.com wrote:
I agree about the documentation but when unfortunately for some of us
Google did not exsits. You guys do not know how good you have it

I remember back when I was a kid I had to walk to school ... in the
snow ... ten miles .... up hill .... both ways .........
You're lucky you had snow! When *I* was young, we only had ice falling
out of the sky (snow had not yet been invented), and the ice pellets
were the size of grapefruits!



Feb 1 '07 #19
How long ago was that?

Robin S.
--------------------------------
"raibeart" <ra******@gmail.comwrote in message
news:11**********************@a75g2000cwd.googlegr oups.com...
When I was working at the Army proving grounds in Yuma, AZ, they were
still using one to process payroll.

The poor maintenance contractor had to maintain the beast.

On Feb 1, 12:54 pm, "Zim Babwe"
<zimba...@doyoureallythinkthisisreal.comwrote:
>Not only did I use punch cards, but one time going up to the window to
give
my stack of cards to the operator, I dropped the cards! Imagine having
to
put them back in the right order? Nightmare!

I wonder if any of the IBM 029 card punch machines still exist?

"RobinS" <Rob...@NoSpam.yah.nonewrote in message

news:A8******************************@comcast.com ...
Oh, yeah? *I* used punchcards to write software! Oooooooooooh. (I
wonder
if anybody will get that.)
Robin S.
--------------------------------
<lord.zol...@gmail.comwrote in message
news:11*********************@h3g2000cwc.googlegro ups.com...
>On Jan 30, 12:57 pm, SomeGrayHa...@gmail.com wrote:
I agree about the documentation but when unfortunately for some of
us
Google did not exsits. You guys do not know how good you have it
>>I remember back when I was a kid I had to walk to school ... in the
snow ... ten miles .... up hill .... both ways .........
>You're lucky you had snow! When *I* was young, we only had ice
falling
out of the sky (snow had not yet been invented), and the ice pellets
were the size of grapefruits!- Hide quoted text -

- Show quoted text -


Feb 1 '07 #20

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jason | last post by:
I have a number of arrays that are populated with database values. I need to determine which array has the highest ubound out of all the arrays. The array size will always change based on the...
17
by: John Bentley | last post by:
John Bentley: INTRO The phrase "decimal number" within a programming context is ambiguous. It could refer to the decimal datatype or the related but separate concept of a generic decimal number....
2
by: Jim Cobban | last post by:
I am using Xerces to read an XML file and load it into a DOM so I can update it and subsequently serialize the updated DOM. The problem I have is that as I traverse the DOM I would like to inform...
1
by: Nick250 | last post by:
We are a real estate office and I need to create an update query based on our main property table (which holds all the information about each property in our town) that will tell me whether a...
9
by: Adam | last post by:
Can someone please help!! I am trying to figure out what a font is? Assume I am working with a fixed font say Courier 10 point font Question 1: What does this mean 10 point font Question 2:...
3
by: Developer in California | last post by:
I am working on developing a generic Web framework using Master Pages in ASP.NET 2.0. What I have done is created a PageRenderer class which has a public method which will retrieve the path of the...
6
by: Jana | last post by:
Greetings Access Gurus! I am working on an app to send batch transactions to our bank, and the bank requires that we place an effective date on our files that is 'one business day in the future,...
9
by: | last post by:
I am interested in scanning web pages for content of interest, and then auto-classifying that content. I have tables of metadata that I can use for the classification, e.g. : "John P. Jones" "Jane...
3
by: Giampaolo Rodola' | last post by:
Hi, I'd like to know if there's a way to determine which is the best buffer size to use when you have to send() and recv() some data over the network. I have an FTP server application which, on...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.