Title: EGR 141 Computer Problem Solving in Engineering and Computer Science
1EGR 141Computer Problem Solving in Engineering
and Computer Science
2Strings
(248) 555-1212 Hello, this is a string! The
article Small Miracles is good This is an
example of a string in Visual Basic _ that
goes for more than one line. It can even
_ go on for three lines.
Quotes within a string
String Continuation
Empty String
3Strings
lblThetext.Text This is the caption for the
control _ called lblThetext!
String continuation
4Strings
Putting the strings together lblText.Text
Hello txtName.Text ! lblText.Text
Hello txtName.Text ! lblText2.Text Welcome
txtName.Text _ to the Grand
Hotel.
Concatenation
5Comments
Begin a comment with a mark This is a
comment lblText.Text Hello Put Hello
in the box Program Header Program
Lab 1 - Hello World Form
frmHello Programmer Robin Bank Purpose
The user can enter their name and when
they click the Show Message button
it will welcome them.
6Variable Names
- VB Rules
- lt 255 characters
- must begin with an alphabetic character
- can't contain punctuation characters (except
underscore "_") - must be unique within the same scope
- case insensitive
- can't be the same as a keyword
- Textbook Conventions
- be meaningful and descriptive
- use consistent abbreviations for same word
- use entire words or initial syllables
- use mixed case, with a capital letter at the
start of each word ("camel-back notation") - Generally between 5 and 20 characters.
7Data Types
- Data Types
- Short. A non-decimal (whole) number with a value
in the range of -32,768 to 32,767. - Integer. A non-decimal (whole) number with a
value in the range of -2,147,483,648 to
2,147,483,647. - Long. A non-decimal (whole) number with a value
in the range of -9,223,372,036,854,775,808 to
9,223,372,036,854,775,807.
8Data Types
- Data Types
- Single. A floating-point (decimal) positive or
negative number with a value in the range of up
to 3.402823E38 (scientific notation). - Double. A floating-point (decimal) positive or
negative number with a value in the range of up
to 1.79769313486232E308. - Decimal. A decimal number with a value in the
range of up to 79,228,162,514,264,337,593,950,335
. without decimal precision and up to
7.9228162514264337593543950335 with 28 places of
decimal precision. - String. Any number of alphabetic, numerical, and
special characters. - Date. Dates in the range between January 1, 0001
to December 31, 9999 and times in the range
between 00000 to 235959. - Boolean. The value True or False.
9Data Types
- Data Types
- String. Any number of alphabetic, numerical, and
special characters. - Date. Dates in the range between January 1, 0001
to December 31, 9999 and times in the range
between 00000 to 235959. - Boolean. The value True or False.
10Declarations
Dim MyNumber As Long Dim MyDecimal As Double Dim
NumberA, NumberB, NumberC As Long Dim message As
String Dim fName, lName As String Const PI As
Double 3.14159
11Declarations
Built-in Constants System.Drawing.Color.Black Sy
stem.Drawing.Color.Red System.Drawing.Color.Lime S
ystem.Drawing.Color.Yellow System.Drawing.Color.Bl
ue System.Drawing.Color.Magenta System.Drawing.Col
or.Cyan System.Drawing.Color.White
12Usage
Form1.ActiveForm.BackColor System.Drawing.Color.
Red _____________________________________________
____ Me.BackColor System.Drawing.Color.Red
________________________________________________
_
Refers to the current, active form