我只是不明白我的代码出错了。我已经确定了错误行,但我不知道如何纠正它或者是什么导致它。请帮忙,欢迎任何建议。这就是问题所在:就在代码的第2行
Public Class Form2
Dim ThirdForm As New Form3
Dim Randomize()
Dim check As Integer = 0
答案 0 :(得分:2)
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