Compiled In Data

The simplest way to load data into an application is to put the data right into a program’s source code. This method is extremely simple so it is easy to implement and debug. The program loads the data quickly and the data cannot get lost.

If a program needs a simple piece of data that will never change, compiling the data into the code is a perfectly acceptable technique. Example program CompiledIn1, shown in Figure 1.1, uses the following code to load its State ComboBox. The Form’s Load event handler declares and initializes the array states to hold the names of the 50 U.S. states, plus D.C. Then it calls the ComboBox’s Items.AddRange method to add the values to the ComboBox:

Figure 1.1. This program loads a ComboBox with ...

Get Visual Basic® .NET Database Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.