试试下面的:
创新互联从2013年成立,是专业互联网技术服务公司,拥有项目成都网站建设、网站设计网站策划,项目实施与项目整合能力。我们以让每一个梦想脱颖而出为使命,1280元连云港做网站,已为上家服务,为连云港各地企业和个人服务,联系电话:028-86922220
Public Class Form1
Public i As Boolean = False
Delegate Sub MySubDelegate()
Private Sub F()
Label1.Text = (Int(Label1.Text) + 1).ToString
Label1.Text = (Int(Label1.Text) + 2).ToString
End Sub
Private Sub setA()
Dim msd As MySubDelegate = AddressOf F
Me.Invoke(msd)
i = True
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim t1 As Threading.Thread = New Threading.Thread(AddressOf setA)
t1.Start()
Do
Application.DoEvents() '关键
If i = True Then
Exit Do
End If
Loop
End Sub
End Class
把变量定义时增加Shared关键字即可.如:
Private
Shared
AAA
As
String
Public
Shared
AAA
As
String
......
这样AAA在一个应用程序里就是公用的.
------------------------------------------------------
补充:
不可能没用,我都是这样做的.
该控件使用中,自己看吧:
Public
Class
CMB_MemoryTextBox
Inherits
TextBox
#Region
"
变量定义
"
Private
Shared
p_HisData
As
STRU_DATA
'用数据表保存所有控件的历史记录
Private
Shared
p_FileName
As
String
'保存历史记录的文件名
......
您仅仅声明了一个变量,变量在未被赋值时,它指向一个空的地址,所以,它没有被实例化。您给它赋一个值,它就指向您定义的值,就行了。
public module module1
Public i As Integer = 365
end module
在form1中的变量要定义成公用变量,即Public strNum As String
在form2中引用form1的公用变量,例:str1 = form1.strNum即可。