Part 2: Creating graphical interfaces
Two months ago (see issue 349, p44) we introduced the free edition of Microsoft Visual Studio, and walked you through setting up your first program in Visual Basic. What we didn’t touch on is the aspect of Microsoft’s IDE that makes it “visual” and sets it apart from many other development environments – namely, the ability to create rich graphical interfaces for your programs.
In fact, that undersells just how powerful the package is. Visual Studio isn’t just about adding buttons and menus to your code: it allows you to design the GUI first, and then slot in event-driven code to make each element work – a wonderfully intuitive and efficient workflow.
To showcase just how easy it can be, this month we’ll walk through the process of creating a sample graphical application in VB that loads in a text file, sort its lines alphabetically and saves the sorted lines under a new name. And to drive it, we’ll build a rich Windows-native interface using standard buttons, text fields and file requesters.
GETTING STARTED
You can begin the project in the usual way, by opening Visual Studio and selecting “Create a new project”. Then, in the project selector window that opens, choose Windows Forms App, making sure you select the Visual Basic template, rather than the C# one. Windows Forms (or WinForms for short) is a framework that lets you use all the standard Windows