Use the ‘MY’ interface in VB 2005 and Higher

Click Star to Rate Post
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
 

Visual Basic 2005 and Higher contains a unique feature which is the ‘MY’ interface. In fact, Visual Basic is the ONLY .net language at this time that even has this interface. Under the MY interface is a list of categorys ranging from Application to Webservices for you to choose from. You can think of MY as sort of a Shortcut menu. For instance, if you wanted to use the DoEvents() Sub you can do it the MY way or the typical way.

        '
        'Typical way,
        System.Windows.Forms.Application.DoEvents()
        '
        'MY way,
        My.Application.DoEvents()

So the MY way saved a step or 2 if none of the namespaces has been imported.

Another example is playing a sound using the Audio class.

        '
        'Typical way,
        Dim audio As New Microsoft.VisualBasic.Devices.Audio
        '
        audio.PlaySystemSound(Media.SystemSounds.Beep)
        '
        'MY Way,
        My.Computer.Audio.PlaySystemSound(Media.SystemSounds.Beep)

Again, there are a few steps saved using the MY interface. These are just a couple examples of a great many features the ‘MY’ interface gives us VB programmers.

Jason

Leave a Reply

Your email address will not be published.