Presentation is loading. Please wait.

Presentation is loading. Please wait.

EGR 141 Computer Problem Solving in Engineering and Computer Science

Similar presentations


Presentation on theme: "EGR 141 Computer Problem Solving in Engineering and Computer Science"— Presentation transcript:

1 EGR 141 Computer Problem Solving in Engineering and Computer Science
Data Types and Variables

2 Strings “(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

3 Strings lblThetext.Text = “This is the caption for the control “ & _
“called lblThetext!” String continuation

4 Strings Putting the strings together…
lblText.Text = “Hello “ & txtName.Text & “!” lblText.Text = “Hello txtName.Text !” lblText2.Text = “Welcome “ & txtName.Text & _ “ to the Grand Hotel.” Concatenation

5 Comments Program Header 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.

6 Variable Names VB Rules Textbook Conventions <= 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.

7 Data 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.

8 Data Types Data Types Single. A floating-point (decimal) positive or negative number with a value in the range of up to E38 (scientific notation). Double. A floating-point (decimal) positive or negative number with a value in the range of up to E308. 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 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 0:00:00 to 23:59:59. Boolean. The value True or False.

9 Data 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 0:00:00 to 23:59:59. Boolean. The value True or False.

10 Declarations 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 =

11 Declarations Built-in Constants System.Drawing.Color.Black
System.Drawing.Color.Red System.Drawing.Color.Lime System.Drawing.Color.Yellow System.Drawing.Color.Blue System.Drawing.Color.Magenta System.Drawing.Color.Cyan System.Drawing.Color.White

12 Usage Form1.ActiveForm.BackColor = System.Drawing.Color.Red
_________________________________________________ Me.BackColor = System.Drawing.Color.Red Refers to the current, active form


Download ppt "EGR 141 Computer Problem Solving in Engineering and Computer Science"

Similar presentations


Ads by Google