我对VB.net程序有以下问题我正在完成。基本上我有两种形式。 Form1 和 techs 。表单1首先加载,是我的“主页”。我想在 Form1 中引用技术中的变量。我公开宣布这个变量是这样的:
Public jobID As String
然后我在Form1上引用它,如下所示:
Dim job As String = techs.jobID
这是我得到的错误:
An error occurred creating the form. See Exception.InnerException for details. The error is: An error occurred creating the form. See Exception.InnerException for details. The error is: The form referred to itself during construction from a default instance, which led to infinite recursion. Within the Form's constructor refer to the form using 'Me.'
有谁能让我知道这里出了什么问题?
答案 0 :(得分:1)
尝试更改
Public jobID As String
到
Public Shared jobID As String
答案 1 :(得分:1)
实例化第一批技术人员
Dim newtechs As New techs()
然后,将techs.jobID分配给Form1
下的字符串变量Dim job As String = newtechs.jobID