How to Set Up the "Try It" Sample Programs


In that the purpose of the next several topics is to explore the basics of the language, the GUIs for the sample programs presented in those topics will be quite minimal. The sample programs in those topics (which will be referred to as "Try It" programs) will use only the InputBox function for input, the form itself for output, and command buttons for the processing. The form will be used to more or less simulate terminal screen output (similar to the "old days" of DOS-based BASIC). Be aware that most VB applications do not print output to the screen in this manner; future sections will focus more on GUI techniques.


The following example can be used as a model for all examples presented in this section. It is recommended that you save this sample program in its own folder (for example, you might call the folder where you save the sample project below "VBTut-03-01"). You can then copy this folder over to another folder for each subsequent "Try It" sample program. When you open the new, copied folder to do the new example, the basic structure for the program will be there, and you can concentrate on modifying the code behind the "Try It" command button.



Property          Value

(Name)            frmTest

Caption           Test

AutoRedraw        True

Font              Courier New


Property          Value

(Name)            cmdTryIt

Caption           Try It


Property          Value

(Name)            cmdClear

Caption           Clear


Property          Value

(Name)            cmdExit

Caption           Exit






Private Sub cmdClear_Click()




End Sub




Private Sub cmdExit_Click()




End Sub



Private Sub cmdTryIt_Click()


    Dim strName As String


    strName = InputBox("Enter your name:", "Input Test")


    Print "Hello there, "; strName


End Sub








Download the VB project files for the example above here.