Vb.net 创建表单时出错
我只是不明白我的代码哪里出错了。我已经确定了错误所在的线路,但我不知道如何纠正,或者是什么原因导致了错误。请帮忙,任何建议都欢迎。问题就在这里:就在代码的第2行Vb.net 创建表单时出错,vb.net,winforms,Vb.net,Winforms,我只是不明白我的代码哪里出错了。我已经确定了错误所在的线路,但我不知道如何纠正,或者是什么原因导致了错误。请帮忙,任何建议都欢迎。问题就在这里:就在代码的第2行 Public Class Form2 Dim ThirdForm As New Form3 Dim Randomize() Dim check As Integer = 0 Dim是在声明变量时使用的关键字,而不是在调用函数时使用的关键字 Randomize()是一个初始化随机数生成器的函数,您不能在类的任何方法之外调用它 Publ
Public Class Form2
Dim ThirdForm As New Form3
Dim Randomize()
Dim check As Integer = 0
Dim是在声明变量时使用的关键字,而不是在调用函数时使用的关键字 Randomize()是一个初始化随机数生成器的函数,您不能在类的任何方法之外调用它
Public Class Form2
Dim ThirdForm As New Form3 ' Declare and initialize the variable ThirdForm
Dim check As Integer = 0 ' Declare and initialize the variable check
' Inside a form constructor....
Public Sub New()
Randomize() ' Call the function that initializes the random-number generator
End Sub
Public Sub Form_Load(sender as Object, e As EventArgs) Handles MyBase.Load
' In alternative you call it inside the Form_Load event.
' Randomize() ' Call the function that initializes the random-number generator
End Sub
您不必
Dim
方法,您可以这样调用它们:Randomize()
。异常详细信息和表单代码会有所帮助。作为旁注,我不认为“Dim Randomize()”是正确的。当我删除“Dim”时,随机化方法会显示错误声明。以下是异常详细信息:创建表单时出错。有关详细信息,请参见Exception.InnerException。错误为:创建表单时出错。有关详细信息,请参见Exception.InnerException。错误是:表单在从默认实例构造时引用了自身,这导致了无限递归。在表单的构造函数中,使用“Me”引用表单。您发布的代码无法生成此异常消息。发布更好的代码。在实现您的建议后仍然不起作用。请解释什么不起作用。您是否有任何错误消息?问题已解决,已从此链接获得帮助: