Chapter2 - Chapter 2 Fundamentals Sample Programs...

Info icon This preview shows pages 1–15. Sign up to view the full content.

View Full Document Right Arrow Icon
Chapter 2 Fundamentals
Image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
2 Sample Programs HelloWorld Output to Screen TwoTimesNumber Input from Keyboard, Math Operators, Assignment Statements, Variables Hypotenuse Message Box, Double Variables, Math Module, Gravity Order of Operations, Input Box, Formatting Numbers Perimeter Modulus Operator, Integer Division, Character Variables, Detailed Format Number
Image of page 2
3 Creating a Console Application Start VB.NET Select New Project on the start page Select Visual Basic Projects Select Console Application Enter “HelloWorld” as the name of the project and select a folder to save the project
Image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
4 Current Screen VB.NET automatically creates a few lines of starter code This program is not capable of doing anything We will make the program display a short message on the screen First, we will talk about program structure …
Image of page 4
5 Modules There has to be at least one module in every project VB.NET IDE assigns a default name to each module The name of the module can be changed For example Module1.vb can be changed to HelloWorld.vb To change the name of the module click on: File Save Module1.vb As…
Image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
6 Subroutines Every module contains one or more subroutines. The main subroutine (and there is only one main subroutine) is where the program execution begins The main subroutine starts with Sub Main() and ends with End Sub
Image of page 6
7 Complete and Run the Program Type the following line inside the main subroutine Save the program by clicking on: File Save Module There are two options to run the program Click on: Debug Start Without Debugging Press F5
Image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
8 Output Screen The cursor is set at the start of the next line after printing its text.
Image of page 8
9 Sample Program Two Times Number Write a program that lets the user enter a number, multiplies this number by two and displays the result on the screen. New Concepts Integer and string variables, Console Input, Console Output with Console.Write(), Assignment statement (=), Multiplication operator (*)
Image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
10 Creating the Program
Image of page 10
11 Auto-complete Part of the user-friendliness of VB.NET shows when one writes a code. The syntax for calling the function or subroutine of a VB object such as Math or Console is “ objectName.objectFunction ”. Well, the coder is not expected to remember all the existing functions of each object, so VB has an auto-complete feature to help the coder. As soon as he or she types the “.”, an list-box unfolds next to the “.” and containing all the existing functions, subroutines, and objects of the initial object.
Image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
12 Running the Program Variable Value strNumber Number TwiceNumber “23” 23 46
Image of page 12
13 Sample Program Output Note that the input “23” is on the same line as “Please enter an integer :” Program Code
Image of page 13

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
14 Sample Program Output If the user does not input an integer the computer will try and store the input as integer.
Image of page 14
Image of page 15
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern