Hello,
I'm a beginner in VB and I'm having trouble with my code. It's a prime number calculator. Here is the function:
Public Function prime(x As Integer)
Dim primes(0) As Integer
primes(0) = 2
For y = 2 To x
bound= UBound(primes)
For Index = 0 To bound
If (y Mod primes(Index)) = 0 Then
Exit For
End If
Next Index
If Index = bound Then
ReDim Preserve primes(boun + 1)
primes(bound + 1) = y
End If
Next y
End Function It receives the argument x passed by main.
When I run the code I get "Array already dimentioned."