-
How do you tell if a number is even or odd..
is there some function out there somewhere to tell if a number is even or
odd in VB?
-
Re: How do you tell if a number is even or odd..
>is there some function out there somewhere to tell if a number is even or odd in VB?
Just use the Mod operator.
If n Mod 2 Then
Debug.Print "n is odd"
Else
Debug.Print "n is even"
End If
Mattias
____________________________________________
Mattias Sjögren - mattiass @ hem.passagen.se
http://hem.spray.se/mattias.sjogren/
-
Re: How do you tell if a number is even or odd..
well....
you could use:
Dim x as Integer
Dim Even as Boolean
if x Mod 2 = 0 then Even = True else Even = false
Jonas L. Jensen
-
Re: How do you tell if a number is even or odd..
Odd = CBool(n mod 2)
Even = Not Odd
Sheldon
CS Schmidt <CSchmidt@pobox.ci.boise.id.us> wrote in message
news:395913f1$1@news.devx.com...
>
> is there some function out there somewhere to tell if a number is even or
> odd in VB?
-
Re: How do you tell if a number is even or odd..
Just to be different <g>
If your Number is in string form (say, from a TextBox), a String variable or
a Variant variable, then
Even = Number Like "*[02468]"
Odd = Number Like "*[13579]"
Rick
CS Schmidt <CSchmidt@pobox.ci.boise.id.us> wrote in message
news:395913f1$1@news.devx.com...
>
> is there some function out there somewhere to tell if a number is even or
> odd in VB?
-
Re: How do you tell if a number is even or odd..
So like maybe it could be yet more efficient, like oh,
say, placing those values in a resource file? Oh, yeah!
Sheldon
Rick Rothstein <fnroth@aosi.com> wrote in message
news:395922c7$1@news.devx.com...
> Just to be different <g>
>
> If your Number is in string form (say, from a TextBox), a String variable
or
> a Variant variable, then
>
> Even = Number Like "*[02468]"
>
> Odd = Number Like "*[13579]"
>
> Rick
-
Re: How do you tell if a number is even or odd..
Shelly Rosenfeld <ShellyRo@worldnet.att.net> wrote in message
news:39591804@news.devx.com...
>
> Odd = CBool(n mod 2)
> Even = Not Odd
>
> Sheldon
>
> CS Schmidt <CSchmidt@pobox.ci.boise.id.us> wrote in message
> news:395913f1$1@news.devx.com...
> >
> > is there some function out there somewhere to tell if a number is even
or
> > odd in VB?
and another variation:
odd=cbool(n and 1)
-
Re: How do you tell if a number is even or odd..
You bit-wise guys are killin' me! <g>
Sheldon
bob butler <butlerbob@my-Deja.com> wrote in message
news:395931f2@news.devx.com...
> > CS Schmidt <CSchmidt@pobox.ci.boise.id.us> wrote in message
> > news:395913f1$1@news.devx.com...
> > >
> > > is there some function out there somewhere to tell if a number is even
> or
> > > odd in VB?
>
> and another variation:
>
> odd=cbool(n and 1)
>
>
>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|