Click here to Skip to main content
15,898,373 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have the following code which generates an array of numbers from 0-10. I am using SharpDevelop IDE and it compiles and runs just fine. However, i need the code to run on ideone.com. Over there i get an error "error VBNC30451: 'ArrayList' is not declared. It may be inaccessible due to its protection level.", I have no idea where i went wrong, any suggestions or fixes?


VB
Module Module1

    Sub Main()
    	
        makeArray(10,0,10)
        Do Until (Console.ReadKey.Key = ConsoleKey.Escape)
        
Loop
        
    End Sub 

    Public Function randomNum(ByVal high As Integer, ByVal low As Integer) As Integer
    	Dim randomValue As Integer
 		randomValue = CInt(Math.Floor((high - low + 1) * Rnd())) + low
 		return randomValue
    End Function 
    
    
    Public Function checkExist(ByVal numbers() As Integer,ByVal searchval As Integer,ByVal size As Integer ) As Integer
    	For value As Integer =0 To size
    		If searchval = numbers(value) Then
    		'	Console.WriteLine("found")
    			Return 3
    		End If
    	Next
    	Return 4
    End Function 
    
    
    
    public Function makeArray(ByVal high As Integer, ByVal low As Integer, ByVal size as Integer) as String()
    	Dim count as Integer
    	Dim random As Integer
    	Dim arra As New ArrayList()
    	Dim dif = size-1
	
	' Dim arra As Integer() = New Integer(19) {}
	'Dim arra(20) As Integer
	For index As Integer = 0 To size+9
    	random =(randomNum(10,0))
    	if Not (arra.Contains(random)) Then
    		count = count +1
    		'Console.writeline("Already contains generating new number")
    		random = randomNum(10,0)
    		while (arra.Contains(random) = true)
    			random = randomNum(10,0)
    		End While	
    	End If
    	If arra.Contains(random) = false
    		arra.add(random)
    		End If
    		
    		Next
    			'Console.WriteLine(count)
    			For Each item As String In arra
    Console.WriteLine(item)
Next
    
    
    End Function

End Module
Posted
Updated 29-May-15 8:55am
v2
Comments
[no name] 29-May-15 15:24pm    
Try adding Imports System.Collections

Then after you do that, probably because you are using an outdated ArrayList and trying to return an array of strings from your function.

1 solution

As mentioned in the comments, you need to import the proper namespace for that to work. If you look at ideone they aren't loading any namespaces for you.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900