|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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 |
|
#2
|
||||
|
||||
|
CInt(j/2) will cast the result into an integer value.
|
|
#3
|
|||
|
|||
|
thank you.
|
|
#4
|
|||
|
|||
|
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 |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > Odd/Even Code |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|