110 pts.
 LISTBOX
I load list box with file data of 5 elements(k2,k2,k3,k4,k5) with up to 10000 results

I get the sum of these elements to be some integer(3,6,7,8,9,11)

I write a code to eliminate some results like this

If (k1+k2+k3+k4+k5) <> 3 or

(k1+k2+k3+k4+k5) <> 6 or

If (k1+k2+k3+k4+k5) <> 7 or

(k1+k2+k3+k4+k5) <> 8 or

If (k1+k2+k3+k4+k5) <> 9 or

(k1+k2+k3+k4+k5) <> 11  then

listbox.add(k1 " ;" & _

k2 " ;" & _ etc

Is it possible to write a code that reflects all these integer(3,6,7,8,9,11) at ones?

 



Software/Hardware used:
ASKED: March 27, 2010  12:40 AM
UPDATED: March 29, 2010  2:33 PM

Answer Wiki:
First, I would like to bring to your attention the fact that when using OR conditions the final result will be true if at least one of the conditions is met (all other conditions don't even need to be evaluated). If you were doing something like this <pre>If (k1+k2+k3+k4+k5) <b><> 3 AND</b> (k1+k2+k3+k4+k5) <b><> 6 AND</b> (k1+k2+k3+k4+k5) <b><> 7 AND</b></pre> or this: <pre>If (k1+k2+k3+k4+k5) <b>= 3 OR</b> (k1+k2+k3+k4+k5) <b>= 6 OR</b> (k1+k2+k3+k4+k5) <b>= 7 OR</b></pre> You could use an array and the <a href="http://msdn.microsoft.com/en-us/library/system.array.indexof.aspx">IndexOf function</a>. Something like this (you might need to change the "<> -1" to "= -1" below): <pre> Dim myArray() As Integer = New Integer() {3, 6, 7, 8, 9, 11} ... If Array.IndexOf(myArray, k1+k2+k3+k4+k5) <> -1 Then listbox.add(... End If</pre> -CarlosDL
Last Wiki Answer Submitted:  March 27, 2010  1:31 am  by  carlosdl   63,580 pts.
All Answer Wiki Contributors:  carlosdl   63,580 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

To be more emphatic, the condition in the original question will always evaluate to true, and thus it is useless.

 63,580 pts.