Click here to Skip to main content
15,886,807 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:
VB
Dim comphost as string
comphost = machinename.text

I think I am on the right path, but I need help.
Posted
Updated 17-Nov-11 2:25am
v2
Comments
André Kraak 17-Nov-11 8:25am    
Edited question:
Added pre tags
Spelling/Grammar

1 solution

It all depends on what you want to do with the variable. What will the UserControls do with this information ?

In answer to your comment. You should create a public property in your main form, something like this:-

VB
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
VB
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!
 
Share this answer
 
v2
Comments
Zachary.shupp 17-Nov-11 8:29am    
all i want it to do is use the machine name that goes in the text box so the other user controls can use it as well. I have one user control that pulls hard drive info and another that pulls networking infor and all they need is the machine name. If you can help that would be great.
Wayne Gaylard 17-Nov-11 8:35am    
Then you should create a public property on your main form, that gets passed to the user controls through their constructor, as and when they get created.
Zachary.shupp 21-Nov-11 8:27am    
sorry for such a late response but i have tried that and i m still having issues. I have the text box called comphost, and the usercontrol it sits in is call uctrl_header. I dont understand how i tell the code above how to pull the text from the text for the comphost. Forgive me i am new to visual basic. thanks for the help
Zachary.shupp 17-Nov-11 10:19am    
could you give me an example of what it should look like for declaring that text box as a vairable called comphost

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900