1 workshop 4 (b): visual basic test project mahidol university june 13, 2008 paul evenson university...

14
1 Workshop 4 (B): Visual Basic Test Project Mahidol University June 13, 2008 Paul Evenson University of Delaware Bartol Research Institute

Upload: christian-shaw

Post on 28-Dec-2015

217 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 1 Workshop 4 (B): Visual Basic Test Project Mahidol University June 13, 2008 Paul Evenson University of Delaware Bartol Research Institute

1

Workshop 4 (B):Visual Basic Test Project

Mahidol University

June 13, 2008

Paul EvensonUniversity of DelawareBartol Research Institute

Page 2: 1 Workshop 4 (B): Visual Basic Test Project Mahidol University June 13, 2008 Paul Evenson University of Delaware Bartol Research Institute

2

Starting a New Project

• Make an empty folder to hold your project

• Select the type of project and press Open

Page 3: 1 Workshop 4 (B): Visual Basic Test Project Mahidol University June 13, 2008 Paul Evenson University of Delaware Bartol Research Institute

3

Select Your Options

• Critical Options:• Editor: Require Variable Declaration• Environment: Prompt to Save Changes

Page 4: 1 Workshop 4 (B): Visual Basic Test Project Mahidol University June 13, 2008 Paul Evenson University of Delaware Bartol Research Institute

4

Select Names and Components

• Name the project and the initial form• Be sure the controls you need are loaded• Save everything in your new directory• Examine files with text editor

Page 5: 1 Workshop 4 (B): Visual Basic Test Project Mahidol University June 13, 2008 Paul Evenson University of Delaware Bartol Research Institute

5

Place Control and Adjust Properties

Page 6: 1 Workshop 4 (B): Visual Basic Test Project Mahidol University June 13, 2008 Paul Evenson University of Delaware Bartol Research Institute

6

Run the Program – It Works!

Page 7: 1 Workshop 4 (B): Visual Basic Test Project Mahidol University June 13, 2008 Paul Evenson University of Delaware Bartol Research Institute

7

Setting Control Properties

• Note that the “Backcolor” property is a long integer• At “Design Time” you can set it with a “drop down” menu

Page 8: 1 Workshop 4 (B): Visual Basic Test Project Mahidol University June 13, 2008 Paul Evenson University of Delaware Bartol Research Institute

8

Double Click a Control to Open the Code Window for Its Events

• Any code you add here is executed every time the event occurs• Here we add the instruction to change the backcolor to green• Now run the program again

Page 9: 1 Workshop 4 (B): Visual Basic Test Project Mahidol University June 13, 2008 Paul Evenson University of Delaware Bartol Research Institute

9

Now Try More Elaborate Code

Page 10: 1 Workshop 4 (B): Visual Basic Test Project Mahidol University June 13, 2008 Paul Evenson University of Delaware Bartol Research Institute

10

Making Your Execute File

You can now run this like any other program

Page 11: 1 Workshop 4 (B): Visual Basic Test Project Mahidol University June 13, 2008 Paul Evenson University of Delaware Bartol Research Institute

11

Adding a “Pure Code” Module

This type of module is the proper way to include subroutines that can be called from anywhere in your program

Page 12: 1 Workshop 4 (B): Visual Basic Test Project Mahidol University June 13, 2008 Paul Evenson University of Delaware Bartol Research Institute

12

Towards Cleaner Code…

• Define the variables as Global in the code module

• Set them only once in the “Load” event on the main form

• They are now available to anyone

• If you don’t like the shade of red, you can change it once, and it will change everywhere

Page 13: 1 Workshop 4 (B): Visual Basic Test Project Mahidol University June 13, 2008 Paul Evenson University of Delaware Bartol Research Institute

13

Add Another Label Control

Page 14: 1 Workshop 4 (B): Visual Basic Test Project Mahidol University June 13, 2008 Paul Evenson University of Delaware Bartol Research Institute

14

Adding the Communications