storage.googleapis.com · web viewvisual basic 2010 how-to-use guide express edition it might be...

19
It might be Visual Basic 2010 Express Edition How - To-

Upload: others

Post on 01-Jan-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: storage.googleapis.com · Web viewVisual Basic 2010 How-To-Use Guide Express Edition It might be said: Ch.1 Pseudo Code Pseudo code is the way you can put commands in logical that

It might be said:

Visual Basic 2010

Express Edition

How-To-Use Gui

Page 2: storage.googleapis.com · Web viewVisual Basic 2010 How-To-Use Guide Express Edition It might be said: Ch.1 Pseudo Code Pseudo code is the way you can put commands in logical that

It might be said:

It might be said:

Ch.1 Pseudo Code Pseudo code is the way you can put commands in logical that which the program can understand and execute. For example,

Public Class frm example

If washing dishes = true Then

Hold Plate

End If

If plate.held = true Then

Wash

Scrub

Wash

Put on rack

End If

End Class.

Now here’s the thing. This piece of code is not independent. You need to tell the computer first the “held” is a variable, what is “wash” and “scrub” and what is “rack”.

Notice that phrases like “wash and scrub and wash again” don’t work at all. This will only make the program needlessly harder to do and sometimes this is a complete fragment for the program. However, you could do something like

Scrub with sponge

Wash with little water

How-To-Use Gui

Page 3: storage.googleapis.com · Web viewVisual Basic 2010 How-To-Use Guide Express Edition It might be said: Ch.1 Pseudo Code Pseudo code is the way you can put commands in logical that

It might be said:

Dry with cloth

This will engage the user more but of course this is a bit more

time consuming. I’d really rather that you don’t just add these things

halfway through because this will just make finish later than you

expect.

Remember that something as simple as a “ . ” if forgotten can

glitch the entire program and it won’t work. When using VB, it will

automatically notify if you debug and there is an error. But not

always is it something you can solve.

Ch.2 Careful Tips If you save your program, NEVER change its name or the

location of one of the files. You will realise that all your work is

Page 4: storage.googleapis.com · Web viewVisual Basic 2010 How-To-Use Guide Express Edition It might be said: Ch.1 Pseudo Code Pseudo code is the way you can put commands in logical that

It might be said:

in one folder, and that there are numerous other files inside.

DO NOT rename or change their location. This is from

experience: sometimes you might have to delete and start

again. To change its location, change the MAIN FOLDER’S

LOCATION ONLY. Use Cut/Paste or Right Click > Send To.

Always click save all so that all your files are stored or updated,

and this is especially most important on your first save and

when you have been working with multiple forms.

If you come across an error that you don’t understand, then

you can try to look through your code for anything underlined

like this: “ .” IIIf none are found, then you might as well search

it up.

Ch.3 Coding for an object In designer mode, to code for an object you need to

double click it, which will open a new “Private Sub” in code

view. This is basically an area specific for the code of that

Page 5: storage.googleapis.com · Web viewVisual Basic 2010 How-To-Use Guide Express Edition It might be said: Ch.1 Pseudo Code Pseudo code is the way you can put commands in logical that

It might be said:

particular object. When I say “object”, I mean anything you

see there, like a picture box or label and so on.

That is, if you have a button called “button1” and a picture

box called “Pic1” in designer mode, and Pic1 is invisible, you

double click button1 and you get this:

Private Sub button1_Click (…)

End SubYou type in code between those 2 lines that appear automatically in code view once you double click button1. Now to make pic1 appear when you click button1, type in this: Private Sub button1_Click (…) Pic1.ShowEnd SubNow when I click button1 while debugging, Pic1 will appear.

Ch.4 Just before your first program... This is the fun part. Now we will start learning VB. You need to

understand the main components of the software.

The VB welcome screen:

Page 6: storage.googleapis.com · Web viewVisual Basic 2010 How-To-Use Guide Express Edition It might be said: Ch.1 Pseudo Code Pseudo code is the way you can put commands in logical that

It might be said:

When you open VB, you will be welcomed by a large set of

instructions credits and all that. On the top right click “New

project” to start

Next you will see this:

Select “Windows Form”

The SOLUTION EXPLORER and PROPERTIES PANEL

The solution explorer is the top-right panel by default, through which

you see your FORMS. The properties panel is directly under, and the

name is self-explanatory. You click an object once to select and then

choose the property to change. From here you can rename objects,

Page 7: storage.googleapis.com · Web viewVisual Basic 2010 How-To-Use Guide Express Edition It might be said: Ch.1 Pseudo Code Pseudo code is the way you can put commands in logical that

It might be said:

change back colour and forecolour, change the text, add a background

image, and add an actual image for a picture box and so on.

The TOOL BOX

The tool box is usually hidden at top-left.

Hover the mouse for it to open.

Using the tool box, you can

insert all available objects.

You can insert labels,

buttons, picture boxes,

timers, and menu strips.

Ch.5 1-4 Review Questions:

Context Questions

1)What is Pseudo code?

Page 8: storage.googleapis.com · Web viewVisual Basic 2010 How-To-Use Guide Express Edition It might be said: Ch.1 Pseudo Code Pseudo code is the way you can put commands in logical that

It might be said:

2)Where do I find all available objects?

3)How Can I change the name of “button1” to

“btn1”?

Activities:

1) I have a picture box called “PictureBox543” and a

button called “btn1”. PictureBox543 is invisible. What is

the code that makes PictureBox543 appear when I click

btn1?

2) Make a pseudo code for washing doing your

homework. Include your start and end time, the

subjects and their corresponding time, and break

time.

Challenge:

1) Draw a button and change its size. Then change its

name to “btn1” 2) Now change the text of btn1 to “wow”

3) Change Font of btn1 to something cool

4) Turn off auto size for btn1 and reshape it

Page 9: storage.googleapis.com · Web viewVisual Basic 2010 How-To-Use Guide Express Edition It might be said: Ch.1 Pseudo Code Pseudo code is the way you can put commands in logical that

It might be said:

5) Change btn1’s forecolour

6) Change back colour OR add a background image.

7) Repeat the above with a label called “lblwow”

8) Add a picture box and make a cool picture

When you are done, you should be able to

understand my instructions while using VB.

As for the code, it’s not something you learn by

memorizing, rather this comes by practice. You

should be able to understand some basic commands

after 1 or 2 programs. You are not a beginner any

more, and here is your first step to make things work.

Ch.6 Program 1: Welcome to VB!! This program builds on the following VB skills:

Playing with the visibility of objects while debugging.

Basic Knowledge of basic VB controls.

Getting Started:

Page 10: storage.googleapis.com · Web viewVisual Basic 2010 How-To-Use Guide Express Edition It might be said: Ch.1 Pseudo Code Pseudo code is the way you can put commands in logical that

It might be said:

What will it do?

Show/Hide objects.

What will it have? Rename them:

A start button btnStart

A quit button btnQuit

A “Go!” Button btnGo

A panel pnl1

A label “Wow” lblwow

A label “This so cool!” lbltsc

A label “I like VB” lblilvb

A label “Welcome to VB” lblHeading

A label “Click Start!” lblsubHeading

A label “Click Go! And see what happens!” lblgo

A label “Yeah!” lblyeah

A label “Way to go!” lblwtg

Designing the program1. Add the btnGo. Note that the names I used up in blue are the text

corresponding to each object. So btnGo should read “Go!”

2. Add the lblGo. Remember to turn off auto size at all times and make

things look cool and attractive. Don’t forget the background.

Page 11: storage.googleapis.com · Web viewVisual Basic 2010 How-To-Use Guide Express Edition It might be said: Ch.1 Pseudo Code Pseudo code is the way you can put commands in logical that

3. The btnGo should be “centre-down” and the lblGo “centre-up”

4. Now add lblwow, lbltsc, lblilvb, lblyeah, and lblwtg. MAKE THEM INVISIBLE.

5. Add btnQuit.

Now it should look like this:

1. Now make a panel that covers the entire form , not bigger.

Rename it “pnl1”. Make its back colour transparent.

2. Notice that the stuff under are hidden right now. Don’t

worry. Add the remainder labels. (lblHeading and

lblsubHeading, and remember their corresponding texts

mentioned above). Enlarge them as much as possible(Turn

off auto size)

3. Add the btnStart. Put it in the middle of the screen.

4. Now your screen should look like this.

5. Now you we will start the code.

Page 12: storage.googleapis.com · Web viewVisual Basic 2010 How-To-Use Guide Express Edition It might be said: Ch.1 Pseudo Code Pseudo code is the way you can put commands in logical that

This will make the missing labels appear when you click Go.

Coding the events

1. Double click on btnStart and enter the following code:

pnl1.Show ()

2. In VB code view, at the top of the screen there are 2

dropdown boxes: The ‘Class Name drop down box’ found on

the top left, and next to it directly is the ‘Method Name

drop down box’

3. From the class name drop down box choose btnGo and form the

Method name drop down box choose “click”. Enter the following code:

Lblwow.Show()

Lbltsc.Show()

Lblilvb.Show()

Lblyeah.Show()

Lblwtg.Show()

4. From the class name drop down box choose btnQuit and form the

Method name drop down box choose “click”. Enter the following code:

End

This makes the program end or terminate when you click btnQuit

Running your project Click on the green play button on the top and start debugging. The panel

should appear first. Make sure the start button hides the panel, the quit button

terminates the program, and the Go button shows the missing labels.

Saving your project

Page 13: storage.googleapis.com · Web viewVisual Basic 2010 How-To-Use Guide Express Edition It might be said: Ch.1 Pseudo Code Pseudo code is the way you can put commands in logical that

Click on save all and rename the file what you want. I suggest you don’t

drag anything thing at all from a location to another or the program won’t

work. If you want to change the location, then use right-click, copy and paste.

NEVER rename anything.

Extensions

1. Add more labels

2. Make another button that hides those labels and shows

another set of labels

3. Make an object appear by hiding the previously shown object,

and you can use the aid keyboard controls.

4. HINT: You might need a timer.

Good Day!! Have fun with those ready programs for you!!

Game C hooser

Pack your bag