VB.NET代码在系统IDE上编译良好,但在在线IDE上失败 [英] VB.NET Code compiles fine on system IDE, but fails on online IDE

查看:92
本文介绍了VB.NET代码在系统IDE上编译良好,但在在线IDE上失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码生成0-10的数字数组。我正在使用SharpDevelop IDE,它编译并运行得很好。但是,我需要在ideone.com上运行代码。在那里我得到一个错误错误VBNC30451:'ArrayList'没有声明。由于它的保护级别,它可能无法访问。,我不知道我哪里出错了,有什么建议或修正吗?





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?


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

推荐答案

如评论中所述,您需要导入适当的命名空间才能工作。如果您查看ideone,他们不会为您加载任何名称空间。
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.


这篇关于VB.NET代码在系统IDE上编译良好,但在在线IDE上失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆