Team Fly |
Page 48
If e.KeyCode = Keys.N And e.Control = True Then 'they pressed CTRL+N searchnext() 'respond to this key combination Exit Sub End If End Sub
Before VB.NET, you put a graphic into a PictureBox with this code:
Set Picture1.Picture = LoadPicture(''C:\Graphics\MyDog.jpg")
Now in VB.NET, LoadPicture has been replaced with the following code:
PictureBox1.Image = Image.FromFile("C:\Graphics\MyDog.jpg")
Although .NET applications avoid using the Registry, you may still nonetheless need to access it. Where should a VB.NET programmer store passwords or other customization information (such as the user's choice of default font size) instead of the Registry that you've used for the past several years? Cookies? What goes around comes around. You can go back to using good old once-disgraced .INI files, or similar simple text files (though they can be deleted). They are, however, quick and easy, and using them avoids messing with the Registry.
In VB6 and before, you could use API commands such as RegQueryValueEx to query the Registry. Or you could employ the native VB Registry-related commands such as GetSetting, like this:
Print GetSetting(appname := "MyProgram" , _ section := "Init" , key := "Locale" , default := "1")
If you must use the Registry, here's how to access it from VB.NET. In VB.NET, you can query the Registry using the RegistryKey object. Type Listing 2.13 into a button's Click event.
LISTING 2.13: MANAGING THE REGISTRY |
Private Sub Button1_Click_1(ByVal sender As System.Object, _ |
Team Fly |