Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old August 11th, 2003, 08:01 AM
wbrianpower wbrianpower is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 6 wbrianpower User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Angry Odd/Even Code

I have a counter code, and I need to tell if it is odd or even...

here is the code I tried to use, but don't think works....

If j = Even Then
Worksheets("Members").Cells((j + 3), 41).Value = 9000 + j
Worksheets("Members").Cells((j + 3), 42).Value = 1000 + i
Worksheets("Members").Cells((j + 3), 43).Value = 2000 + (i + 1)
Worksheets("Members").Cells((j + 3), 44).Value = "WBracing"
Worksheets("Members").Cells((j + 3), 45).Value = CmbBrace.Value
Else
Worksheets("Members").Cells((j + 3), 41).Value = 9000 + j
Worksheets("Members").Cells((j + 3), 42).Value = 1000 + (i + 1)
Worksheets("Members").Cells((j + 3), 43).Value = 2000 + i
Worksheets("Members").Cells((j + 3), 44).Value = "WBracing"
Worksheets("Members").Cells((j + 3), 45).Value = CmbBrace.Value
End If

For some reason, I think that Even is not a reconized command...
Is there some way to say,

if j/2 = integer (ie, no .5 at the end)

Thanks for the help once again.

Brian

Reply With Quote
  #2  
Old August 11th, 2003, 08:06 AM
Onslaught's Avatar
Onslaught Onslaught is offline
/(bb|[^b]{2})/
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Nov 2001
Location: Somewhere in the great unknown
Posts: 4,834 Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Day 23 h 30 m 30 sec
Reputation Power: 88
Send a message via ICQ to Onslaught
CInt(j/2) will cast the result into an integer value.

Reply With Quote
  #3  
Old August 11th, 2003, 08:34 AM
wbrianpower wbrianpower is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 6 wbrianpower User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
thank you.

Reply With Quote
  #4  
Old August 11th, 2003, 10:56 AM
nopoints nopoints is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Windsor ON, Canada
Posts: 459 nopoints User rank is Corporal (100 - 500 Reputation Level)nopoints User rank is Corporal (100 - 500 Reputation Level)nopoints User rank is Corporal (100 - 500 Reputation Level)nopoints User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 13 h 44 m 22 sec
Reputation Power: 8
Code:
If j Mod 2 = 0 Then ' j is even
Else                ' j is odd
End If

Mod gives you the remainder. when you mod by two the result is either 1 (odd) or 0 (even).
__________________
Programmer's Corner

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > Odd/Even Code


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway