The text of this article is not in this database — only its details are. Read it on the old site: Retrieving Environment variables in VB.NET
2 Comments
Join the conversation! Your thoughts help the community grow.
Sign in to leave a comment.
The text of this article is not in this database — only its details are. Read it on the old site: Retrieving Environment variables in VB.NET
Join the conversation! Your thoughts help the community grow.
Sign in to leave a comment.
Amber NazPosted May 1, 2010, 3:21 AM
IF you want to display System Information in window Application in VB.Net then follow the following Steps: Step 1: Add a ListBox Step 2: Declare the following at the top of the form Imports System.Environment<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p> Step 3: Copy the following code and paste it<o:p></o:p> Private Sub GetEnvironmentVariables()<o:p></o:p> Dim dictEntry As System.Collections.DictionaryEntry<o:p></o:p> For Each dictEntry In Environment.GetEnvironmentVariables()<o:p></o:p> Me.ListBox1.Items.Add("Key : " & (dictEntry.Key.ToString()) & "Value: " & (dictEntry.Value.ToString()))<o:p></o:p> Next<o:p></o:p> End Sub<o:p></o:p> Step 4: Now call this methos on either form load or on button click:<o:p></o:p> I have called this method on form load <o:p></o:p> Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load<o:p></o:p> GetEnvironmentVariables()<o:p></o:p> End Sub<o:p></o:p> Now run the Project<o:p></o:p> And if you only wanted to display a certain Value like ComputerName or UserName then follow the following Steps:<o:p></o:p> Step 1: Add a textbox Step 2: Declare the following at the top of the form Imports System.Environment<o:p></o:p> Step 3: Copy the following code and paste it<o:p></o:p> Private Sub GetEnvironmentVariables()<o:p></o:p> Dim StrUserName As String<o:p></o:p> StrUserName = Environment.GetEnvironmentVariable("USERNAME")<o:p></o:p> Me.TextBox1.Text = StrUserName<o:p></o:p> End Sub<o:p></o:p> Step 4: Now call this methos on either form load or on button click:<o:p></o:p> I have called this method on form load <o:p></o:p> Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load<o:p></o:p> GetEnvironmentVariables()<o:p></o:p> End Sub<o:p></o:p> Now run the Project<o:p></o:p>
Ricardo MartinezPosted Feb 15, 2007, 1:58 PM
Hi, I need the same code but for .net framework windows CE