|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
I am trying to write a sub procedure that takes an array of ten integers and displays to picture box whether the sum of the integers is odd or even. please help
|
|
#2
|
|||
|
|||
|
ok, so assuming you've got a picture for odd and a picture for even
Code:
sumOfArray = 0
for i = lbound(myArray) to ubound(myArray)
sumOfArray = sumOfArray + myArray(i)
next
if sumOfArray mod 2 = 0 then
'even - code to display even picture
else
'odd - code to display odd picture
end if
|
|
#3
|
|||
|
|||
|
Or if you want to just use text, set the FontTransparent property to false and use this:
Code:
sumOfArray = 0
for i = lbound(myArray) to ubound(myArray)
sumOfArray = sumOfArray + myArray(i)
next
if sumOfArray mod 2 = 0 then
picSum.print "Sum is even"
else
picSum.print "Sum is odd"
end if
The .print method doesn't pop up in that autocomplete list thing, but it's there. Really, it is. Last edited by D·Hack : December 5th, 2003 at 10:54 PM. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > Array of ten integers |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|