问题描述
我的总体目标是为远程计算机获取不同的计算机信息.
我有几个用户控件都拉不同的信息.一个用户控件获取信息(机器名),而我需要其他用户控件来查看它.
我的设置方法是,我有一个文本框和一个按钮,然后单击按钮,我希望应用程序提取机器信息.
我已经读过有关全局变量的信息,但是我是编程的新手.
我试过了:
My overall goal is pulling different machine information for remote machines.
I have several user controls all pull different information. One user controls gets the information (machine name) and I need the others user controls to see it.
The way I have it set up is I have a text box and a button and on button click I would like the application to pull the machine information.
I have read about global variables, but I am new to programming.
I have tried:
Dim comphost as string
comphost = machinename.text
我认为我走了正确的道路,但我需要帮助.
I think I am on the right path, but I need help.
推荐答案
Public Property CompHost() As String
Get
return compHost
End Get
Set(ByVal Value As String)
compHost = Value
End Set
End Property
然后在用户控件中创建一个构造函数,该构造函数将字符串作为参数,并在打开它时传递此属性,如下所示:-
公共
then in your user control you create a constructor that takes a string as a parameter and pass in this property when you open it, something like this:-
Public
Class myUserControl
Public Sub myUserControl(compHost As String)
'do something with compHost
End Sub
End Class
也许这会给你一个更好的主意.祝你好运!
Maybe this will give you a better idea. Good luck!
这篇关于从用户控件中的文本框声明文本作为整个应用程序的变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!