Sie sind auf Seite 1von 3

Introduction to Visual Basic (ITSE 1331) Exam 1 Gaddis/Irvine

Hardware
Hardware a computer's physical components.
1. The central processing unit (CPU)
2. Main memory
3. Seconary storage e!ices
". #nput e!ices
$. %utput e!ices
Software
Software programs that run on a computer.
Application software programs that ma&e the computer use'ul
to the user an per'orm general user nees.
Operating system(a set o' programs that manages the
computer's har)are e!ices an controls their processes.
l!orit"m
Algorithma set o' )ell*e'ine steps 'or per'orming a tas& an
escri+es a pro+lem solution.
CPUonly processes instructions )ritten in machine language
#$%ect #riented &ro!rammin!
Object a reusa+le sel'*containe unit. ,as properties- methos-
an e!ents.
Sa!ing a .isual /asic.01T pro2ect
1. Clic& 3ile on the menu +ar- an then clic& Sa!e 4ll on the 3ile
menu.
2. Press Ctrl5Shi't5S on the &ey+oar
3. Clic& the Sa!e 4ll +utton on the stanar tool+ar.
1ning a .isual /asic.01T application
1. Clic& the close +utton on the applications )ino).
2. Clic& 6e+ug on the menu +ar- an then clic& Stop 6e+ugging
on the 6e+ug menu.
3. 6ou+le clic& the Stop 6e+ugging #con on the e7tene Tool
/ar )hile the program is running.
GUI Graphical User Interface! applications are more comple7
'or programmers to )rite.
"#ent proced$rea type o' su+ proceure also &no)n as e!ent
hanlers.
1. 4 correct name 'or an e!ent proceure that )ill +e
e7ecute )hen the user clic&s on a /utton control name
+tn6isplay8ist coul +e +tn6isplay8ist9Clic&. (:emem+er-
control names may not contain spaces.)
2. 4 correct assignment statement 'or a la+el control name
l+lTitle that )oul align the control's te7t )ith the mile an
center o' the control's +ouning +o7 )oul +e
l+lTitle.Te7t4lign;Content4lignment.MileCenter.
"#ent e%amples
1. Clic& a control
2. Change 'ocus o' a control
3. Change contents o' a te7t+o7
Intellisensepro!ies some automatic coe completion )hile
e!eloping a program.
Control<U# elements such as Chec&/o7- Com+o/o7- /utton-
8a+el- Te7t/o7- 3orm- etc.
3or e7ample= t7t0ame.Te7t- the property is Te7t
8a+el control(a +o7 that isplays te7t that cannot +e change or
entere +y the user.
Control &isible property)ill +e isplaye uring esign time
)hen set to 'alse.
Creating &' applications yo$ change control properties
1. Creating the <U# elements that ma&e up the application's user
inter'ace
2. Setting the properties o' the <U# elements
3. >riting programming language statements that respon to
e!ents an per'orm other operations.
'evelo(in! an ((lication
1. Ma&e a list o' methos neee 'or each control
2. Ma&e a list o' the controls neee
3. Create a 'lo)chart or pseuocoe !ersion o' each metho.
&ro!rammin! an ((lication
(eywordhas a special purpose an cannot +e use as a !aria+le
or other ienti'ier.
Comments )emar*s! helps the human reaer o' a program
unerstan the purpose o' program statements (the coe).
Identifiera programmer e'ine name that is not part o' the
.isual /asic programming language. 4ny control )hose name
appears in a programming statement shoul ha!e a escripti!e-
programmer*e'ine name.
+lowcharts and pse$do code use to outline the solution to a
pro+lem. 17ample=
1. Ma&e a list o' methos neee 'or each control.
2. Ma&e a list o' the controls neee.
3. Create a 'lo)chart or Pseuocoe !ersion o' each metho.
,esting a program with sample data to insure that the program
hanles the calculations correctly.
-eb$gging3ining an 'i7ing programming errors.
Compile time errors compilation errors!errors such as
misspelle &ey )ors or incorrect use o' operators.
)$nning an application
1. Clic& the start +utton on the tool+ar.
2. Press the 3$ &ey.
3. Clic& 6e+ug on the menu +ar- an then clic& Start on the
6e+ug menu.
Visual Basic Environment
-isplay the -esigner window clic& .ie) on the menu +ar- an
then on the !ie) menu clic& 6esigner.
A$to hide feat$re )ill cause the )ino) to stay minimi?e as a
ta+ along one o' the eges o' the screen until the mouse cursor is
o!er the ta+.
,oolbar can +e use as a shortcut 'or e7ecuting commans
'oun in the menu.
1. Use to select controls an place on an application 'orm.
-isplay a tooltip hol the mouse cursor o!er a +utton on the
tool+ar or tool+o7 'or a 'e) secons.
,e%t'o% controltypically use to input ata.
,oolbo% purpose is to select controls an place an application
'orm.
)$n time modethe moe in )hich you run an test an
application. Can interact )ith the program as it e7ecutes.
)ritin! a Visual Basic &ro%ect
&is$al 'asic Project.isual stuio creates a 'oler to hol the
solution an pro2ect. >hen a pro2ect is create- it must +elong to
a solution.
Assignment operator uses the e@ual sign. The assignment
statement copies the !alue on its right sie into the item on its
le't. The !alue o' a control's property may +e change )hile the
application is running +y using an assignment statement.
.$ltiplication operatoruses the asteris&.
17amples=
+lPerimeter ; 2 A +l8ength 5 2 A +l>ith
l+lTitle.Te7t ; B.isual /asicB
+ile e%tension./.01T pro2ects sa!e )ith the .pro2 'ile
e7tension.
/oc* all of the controls on a form d$ring design timeright*clic&
on an empty spot on the 'orm- an select the 8oc& Controls
option 'rom the pop up menu.
Code to close a formMe.Close()
Conte%t*sensiti!e helpa help screen that is isplaye )hen the
31 &ey is presse ('or the item that is currently selecte)
*ontents of t"e &ro%ect +older (of a (ro%ect named 'irections)
bin folder0contains the application's e7ecuta+le coe
.y Project folder(contains !arious application settings
'iles
obj folder(hols temporary 'iles that are create uring
the compilation process.
-irections1#bproj(This is the pro2ect 'ile. The pro2ect
'ile contains in'ormation neee +y .isual Stuio a out the
6irections pro2ect. #n >ino)s- you can ou+le*clic& the
pro2ect 'ile an the pro2ect )ill +e loae into .isual
Stuio.
-irections1#bproj1$ser(This 'ile contains in'ormation
a+out .isual Stuio's #61 settings.
+orm21-esigner1#b(This 'ile contains the .isual /asic
coe to generate the 3orm1 'orm an all o' the controls on
it.
+orm21res%(This 'ile contains in'ormation a+out !arious
resources neee +y 3orm1 'orm.
+orm21#b(This 'ile contains .isual /asic coe that you
)rite.
&ro(erties )indow
Properties 3indowlists the properties o' the controls. Cou can
use the o+2ect +o7 on the Properties )ino) to select any o+2ect
in the pro2ect.
1. 4 'e) o' the properties- incluing the 0ame property are
enclose in parenthesis to ma&e them appear at the top o' the
alpha+etical list. 4 programming statement must reer to a
control +y its 0ame property.
&iew the properties window=
1. Pressing the 3" &ey
2. /y clic&ing on the properties icon a+o!e the Solutions e7plorer
)ino).
3. <o to the !ie) menu an the clic&ing properties.
Si4ing handlesappear )hen you select an e7isting control on a
'orm uring esign time.
/abel controluse to create la+els to isplay te7t on a 'orm
)hich cannot +e moi'ie +y the user. #' a la+el control is not
)ie enough 'or the te7t that is )ritten into that control- then the
e7tra te7t is )rappe onto the ne7t line or lines. 17ample= To
isplay the )ors B.isual /asicB in a la+el name l+lTitle )rite
l+lTitle.Te7t ; B.isual /asicB
1. 4utosi?e property o' a la+el control allo)s a la+el to change
si?e to 'it the amount o' te7t in its te7t property.
'o$nding bo%a transparent rectangular area that e'ines a
control's si?e on a 'orm.
6eleting a control 'rom a 'orm
1. Select the control- then use the cut option on the menu +ar
2. Select the control- then hit the elete &ey.
3. Select the control- then select elete 'rom the eit menu.
Undo b$tton on the standard toolbaruse to restore a control i'
it is accientally elete.
Si4e.ode propertya Picture/o7 property that etermines ho)
the control )ill position an scale its graphic image.
+orm'orderStyle propertya property that con'igures a 'orm's
+orerD allo)s or pre!ents resi?ing- minimi?ing- or ma7imi?ing a
)ino). .ali !alues inclue=
1. 3i7e36
2. Si?ea+le
3. 3i7eSingle
*ode )indow
6isplay the Coe )ino)
1. Clic& !ie) coe +utton on the Solution e7plorer )ino).
2. Clic& .ie) on the menu +ar- an then clic& the Coe
comman.
3. Press the 3E &ey.
Code regiona section o' coe that may +e hien 'rom !ie)- or
collapse.
*ontrols
,e%tbo% control use to gather input the user has type on the
&ey+oar. Cou clear a te7t+o7 )ith coe +y assigning a +lan& to
the te7t property.
,e%tbo% and '$tton Controlscan ha!e the 'ocus.
,ab Orderthe orer in )hich controls recei!e the 'ocus.
,ab Order Selection .odelets you !ie) the Ta+#ne7 o' each o'
the controls on the 'orm.
&iew ,ab Order(all controls on a 'orm )ill recei!e the 'ocus +y
clic&ing .ie) on the menu +ar an then Ta+ %rer.
Strin! *oncatenation
Ampersand symbol 5! use to per'orm string concatenation.
,ine continuation
/ine contin$ationto +rea& up a long line o' coe- so that it 'its in
the coe )ino) type a space- 'ollo)e +y an unerscore an
then hit the enter &ey.
Varia$les and -amed *onstants
&ariable(a memory location that hols in'ormation )hile the
program e7ecutes.
-eclaration Statementgi!e !aria+les an constants names- an
speci'y the type o' ata they )ill hol.
6aming &ariable )$les
1. May contain unerscores
2. May contain letters
3. May contain igits (not the 'irst position)
-im Statement to eclare a !aria+le use a 6im statement=
6im !aria+le0ame 4s 6ataType
3or e7ample= 6im str0ame 4s String
6im int8ength 4s #nteger ; 2F
6im ine7 4s #nteger
The 6im statement 'or a class*le!el !aria+le must +e outsie any
proceure- an +et)een the Pu+lic Class statement an the 1n
Class statement.
The 'ollo)ing actions can +e per'orme )ith !aria+les=
1. Copy an store !alues entere +y the user- so they may +e
manipulate.
2. Per'orm arithmetic on !alues.
3. :emem+er in'ormation 'or later use in the program.
6amed constantli&e a !aria+le )hose content is rea*only an
cannot +e change +y a programming statement )hile the
program is running. 4!antages are=
1. They ma&e the program more sel' ocumenting since they can
escri+e the meaning o' the constant !alue.
2. #t is easier to ma&e )iesprea changes to a name constant
throughout a program.
3. The !alue o' the constant cannot +e change )ithin the
program.
". >hen you eclare a constant- you must assign it an initial
!alue.
.aria+les eclare )ith a +utton's clic&*e!ent are local !aria+les.
class7le#el #ariable=
1. can +e eclare any)here +et)een Pu+lic Class an 1n
Class (insie a class)
2. !isi+le to all statements insie the class
3. not local to any proceure
". eclare outsie a proceure
$. accessi+le to all proceures in a class
*onversions
Implicit ,ype Con#ersion)hen you assign a !alue o' one ata
type to a !aria+le o' another ata type- .isual /asic attempts to
con!ert the !alue +eing assigne to the ata type o' the !aria+le.
Option strictin .isual /asic- a con'iguration option that
etermines )hether certain implicit con!ersions are legal.
,oString methodeach o' the .isual /asic ata types has a
ToString metho- )hich returns a string representation o' the
!aria+le calling the metho.
CIntCon!erts a numeric or string e7pression to an #nteger. #' the
e7pression con!erts to a !alue outsie the range o' an #nteger- or
is not a numeric !alue- a runtime error is generate. :ouns to
nearest integer.
CSng(Con!erts a numeric or string e7pression to a Single. #'
the e7pression con!erts to a !alue outsie the range o' a Single-
or is not a numeric !alue- a runtime error is generate. The input
e7pression may contain commas- as in B1-23"B
)eal n$mber assigned to an integer #ariablenarro)ing
con!ersion )hen allo)e. The !alue is either roune o)n)ar
or up)ar. 3or e7ample=
3ormat0um+er(12.2G3- 1) returns 12.3
Type Con!ersion 1rrora runtime error that is generate )hen a
nonnumeric !alue that cannot +e automatically con!erte to a
numeric !alue is assigne to a numeric !aria+le or property. =
)or.in! wit" -um$ers
5 4ition
Su+traction
A Multiplication
H 3loating*point i!ision
I #nteger i!ision
M%6 Moulus (remainer 'rom integer i!ision)
J 17ponentiation
17ample=
ans)er ; 2" Mo K (ans)er is F)
,he precedence of the arithmetic operators8 from the highest to
lowest9
1. 17ponentiation (the J operator)
2. Multiplication an i!ision (the A an H operators)
3. #nteger i!ision (the I operator)
". Moulus (the M%6 operator)
$. 4ition an su+traction (the 5 an operators)
Assignment operator :!the e7pression on the right o' the ;
operator is e!aluate an assigne to the !aria+le on the le't. 3or
e7ample l+l6isplay.Te7t ; t7t#nput.Te7t
Combined Assignment Operators
17ample 1@ui!alent to
5; 7 5; 2 7 ; 7 5 2
; 7 ; $ 7 ; 7 $
A; 7 A; 1L 7 ; 7 A 1L
H; 7 H; y 7 ; 7 H y
I; 7 I; y 7 ; 7 I y
M; str0ame M; last0ame str0ame M last0ame
Events and /et"ods
/oad "#ent Proced$rea proceure that is e7ecute each time a
'orm loas into memory. #' you )ant to e7ecute some coe at
this point- you can )rite the coe in the 'orm's 8oa e!ent
hanler.
"#ent handler(the coe that is e7ecute )hen an e!ent occurs-
such as a +utton is clic&e- a 'orm loas- a mouse o!er- etc.
Message/o7.Sho) methoisplays a Message /o7.
#' you )ant to isplay multiple lines o' in'ormation in a message
+o7- use the constant ControlChars.Cr8' (Cr8' stans 'or carriage
return line 'ee). 0otice that +oth the C an 8 in Cr8' are
uppercase. 17ample 'or one line message=
Message/o7.Sho)(B,ello >orlB)
<eneral 'ormat 'or the metho call that isplays a message +o7=
Message+o7.sho)(Message- Caption- /uttons- #con-
6e'ault/utton)
'ata T0(es
-ate -ata ,ypee'aults to 12=LL=LL 4M- Nanuary 1 o' the year 1
'oolean -ata ,ypee'aults to 3alse
String -ata ,ypese@uence o' characters surroune +y ou+le
@uotes
Integer -ata ,ypeoptional leaing sign- se@uence o' ecimal
igits- 'ollo)e +y optional letter #
-ecimal -ata ,ype%ptional leaing sign- se@uence o' ecimal
igits- optional ecimal point an trailing igits- 'ollo)e +y the
letter 6 or O

Das könnte Ihnen auch gefallen