Question with math loop in vb.net

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Greetings All,

I have a question on a math loop and programming it in VB.net
Here's the logic:

While Num < 0.0998 And > .0801
Num / 2
Loop
Num / 11

I can get most of it but I'm having problems with the syntax and adding the "And" statement.
Help please.

TIA
 
The While phrase should be:


While Num < 0.0998 And Num > .0801

HTH

Rob
 
Try:

While Num < 0.0998 And Num > 0.0801

Num = Num / 2

End While

Num = Num / 11
 
I have a question on a math loop and programming it in VB.net
Here's the logic:

While Num < 0.0998 And > .0801

\\\
While Num < 0.0998 AndAlso Num > 0.0801
...
End While
///
 
I have a question on a math loop and programming it in VB.net
Here's the logic:

While Num < 0.0998 And > .0801
Num / 2
Loop
Num / 11

I can get most of it but I'm having problems with the syntax and adding the "And" statement.


Always be as explicit as you can, (also be sure option Explicit is On)

While (Num < .0998) And (Num > .0801)
....


The comparison operators need values on both sides and the use
of parentheses avoids any ambiguity in what the evaluation order
should be.

Ex

2 * 5 + 7 = ?

(2 * 5) + 7 = 17
2 * (5 + 7) = 24

In the top (?) example the programmer has relied on VB to do the
right thing. Don't do that! Use parentheses to let everyone know
what the correct order of evaluation should be. The same goes
for your comparisons....

HTH
LFS
 
In addition to the other comments you can do:
While Num < 0.0998 And Num > .0801
Num /= 2
Loop
Num /= 11

Hope this helps
Jay
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top