Chapter 2 Writing Your First Program 61
Try creating a release build named MyLucky7 .exe now.
Create an executable file
- On the Build menu, click the Build MyLucky7 command.
The Build command creates a Bin\Release folder in which to store your project (if the
folder doesn’t already exist) and compiles the source code in your project. The result
is an executable file of the Application type named MyLucky7 .exe. To save you
time, Visual Studio often creates temporary executable files while you develop your
application; however, it’s always a good idea to recompile your application manually
with the Build or Rebuild command when you reach an important milestone.
Try running this program outside the Visual Studio IDE now from the Windows
Start menu.
- On the Windows taskbar, click Start.
The next command depends on the version of Windows you’re using.
- If you have Windows 7 or Windows Vista, type run in the Search text box and press
ENTER to open the Run dialog box. If you have Windows XP or earlier, click the Run
command to open the Run dialog box. - Click Browse and then navigate to the C:\Vb10sbs\Chap02\Mylucky7\Bin\Release folder.
- Click the MyLucky7 .exe application icon, click Open, and then click OK.
The Lucky Seven program loads and runs in Windows. Because this is a simple test
application and it does not possess a formal publisher certificate that emphasizes its
reliability or authenticity, you may see the following message: “The publisher could not
be verified. Are you sure you want to run this software?” If this happens to you, click
Yes to run the program anyway. (Creating such certificates is beyond the scope of this
chapter, but this program is quite safe .)
- Click Spin a few times to verify the operation of the game, and then click End.
Tip You can also run Windows applications, including compiled Visual Basic programs, by
opening Windows Explorer and double-clicking the executable file. To create a shortcut
icon for MyLucky7 .exe on the Windows desktop, right-click the Windows desktop, point to
New, and then click Shortcut. When you’re prompted for the location of your application
file, click Browse, and select the MyLucky7 .exe executable file. Click the OK, Next, and
Finish buttons. Windows places an icon on the desktop that you can double-click to run
your program.
- On the File menu, click Exit to close Visual Studio and the MyLucky7 project.
The Visual Studio development environment closes.