1. ## problem to retrieve the primenumbers between1to100

Hi,
i tried writing code which looks like:

Option explicit

Dim i,v
v=1

while v&lt;=100
v=2

While i&lt;=v

if v / i &lt;&gt; 0
i=i+1

End if
wend
if i=v

msgbox ("the printed number is prime")

v=v+1
End if

Wend

I am gettiing syntax errors, any help will be really appreciated.

Regards;
Dileep

2. ## Re: problem to retrieve the primenumbers between1t

You missed "then" in your if statements

if v / i &lt;&gt; 0

should be

if v / i &lt;&gt; 0 then

3. ## Re: problem to retrieve the primenumbers between1t

This may be help..

Dim RangeStart
Dim RangeEnd
Dim iCounter
RangeStart=1
RangeEnd=30

For iCounter=RangeStart to RangeEnd

For iCount=2 to round(iCounter/2)
If iCounter mod iCount=0 Then
Exit for
End If
Next

If iCount=round(iCounter/2)+1 or iCounter=1 Then
print iCounter
End If
Next

Thanks
bcgi

4. ## Re: problem to retrieve the primenumbers between1t

Hi,
Thanks a lot, i have correct my code, but while executing the code i am getting run error at this line

If v / i &lt;&gt; 0 Then

It says:

Division by zero

Any help will be really appreciated

5. ## Re: problem to retrieve the primenumbers between1t

[ QUOTE ]
Hi,
Thanks a lot, i have correct my code, but while executing the code i am getting run error at this line

If v / i &lt;&gt; 0 Then

It says:

Division by zero

Any help will be really appreciated

[/ QUOTE ]

of course... set i=1 first

i = 1
if v / i &lt;&gt; 0
i=i+1

End if

6. ## Re: problem to retrieve the primenumbers between1t

bcgi:

one is not a prime number.So

If iCount=round(iCounter/2)+1 or iCounter=2 Then

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

vBulletin Optimisation provided by vB Optimise v2.6.0 Beta 4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.