Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

VB.NET Faces Off Against Classic VB : Page 7

VB.NET, the .NET Framework, and Visual Studio.NET together form a potent combination that can simplify your code and reduce errors; however, to truly supplant existing versions of VB as a RAD tool, Visual Studio needs Break-Edit-Continue.


advertisement

Read a registry value
Windows, until .NET, depended heavily on the registry. Therefore, it was irritating that classic VB's built-in methods for registry access were limited to a single registry location—HKEY_CURRENT_USER\Software\VB and VBA Program Settings\appname\section\key. Of course, you could use the API to read and write other keys, but it was complicated (click here for an example).

In contrast, reading and writing to the registry is extremely simple in VB.NET. For example, the following subroutine creates the subkey HKEY_CURRENT_USER\Software\VBDotNetDemo, sets the subkey's name to "VBDotNetDemo" and its value to the String "VB.NET," and then displays a message box showing the new value.




Classic VB

Example: http://www.planet-source-code.com/vb/scripts/ShowCode.asp?lngWId=1&txtCodeId=1881




VB.NET

   Private Sub btnWriteRegistry_Click(ByVal sender As _
      System.Object, ByVal e As System.EventArgs) 
      Handles btnWriteRegistry.Click
   
      Dim aKey As RegistryKey
      aKey = Registry.CurrentUser.CreateSubKey _
        ("Software\VBDotNetDemo")
      aKey.SetValue("VBDotNetDemo", "VB.NET")
      MessageBox.Show("The value of the new key " _
         & "'HKEY_CURRENT_USER\Software\" & _
         "VBDotNetDemo' is: " _
         & aKey.GetValue("VBDotNetDemo", _
         "Default value"), _
         "Key Created Successfully")
   End Sub


Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap