Visual Basic comes with a lot of predefined code snippets for selected actions, and you can insert these snippets into your code as needed. Let’s say you want to insert the statements for writing some text to a file, but you have no idea how to access files. In the following example we will print all drivers of our computer.
Imports System.IO Module Module1 Sub Main() For Each drive As DriveInfo In My.Computer.FileSystem.Drives Console.WriteLine(drive.Name) 'printing drive names Next Console.ReadLine() ' waiting for one character to enter from user to pause screen End Sub End Module
Output (on my computer)
C:\ D:\ E:\ F:\ G:\