Presentation on theme: "Pemrograman VisualMinggu …2… Page 1 MINGGU Ke Dua Pemrograman Visual Pokok Bahasan: Console Application Tujuan Instruksional Khusus: Mahasiswa dapat menjelaskan."— Presentation transcript:
Pemrograman VisualMinggu …2… Page 1 MINGGU Ke Dua Pemrograman Visual Pokok Bahasan: Console Application Tujuan Instruksional Khusus: Mahasiswa dapat menjelaskan dan mengaplikasikan console apllication, tipe data, operator aritmatika, relational operator dan message dialogs Referensi: Deitel Deitel, Visual Basic 2008 (2009), How to Program, Prentice Hall. Chapter 3
Pemrograman VisualMinggu …2… Page 2 Agenda Displaying line of text Creating console application Adding Integer Memory concepts Arithmetic Equality and Relational operator Message Dialog to display message
Pemrograman VisualMinggu …2… Page 3 Displaying Line of Text
Pemrograman VisualMinggu …2… Page 4 Module Module1 Sub Main() Console.WriteLine("Wellcome to Visual Basic.NET") Console.ReadKey() End Sub End Module Perbedaan Write dengan WriteLine Fungsi ReadKey() Displaying Line of Text (Continued …)
Pemrograman VisualMinggu …2… Page 5 Creating a Console Application
Pemrograman VisualMinggu …2… Page 6 IDE with an open console application
Pemrograman VisualMinggu …2… Page 7 Renaming the program files in the properties windows
Pemrograman VisualMinggu …2… Page 8 Setting the Startup Object
Pemrograman VisualMinggu …2… Page 9 Writing Code and Using IntelliSense
Pemrograman VisualMinggu …2… Page 10 Parameter Info Window
Pemrograman VisualMinggu …2… Page 11 Running the program from the command prompt
Pemrograman VisualMinggu …2… Page 12 Syntax Error Indicated by the IDE
Pemrograman VisualMinggu …2… Page 15 The ReadLine method cause the program to pause and wait for user input, once the user presses the enter key, the input is returned to the program and execution resumes A Syntax error indicates a violation of visual basic’s rule for creating Adding Integer Summary
Pemrograman VisualMinggu …2… Page 17 Memory Concepts Variable names, such as number1, number2, total, correspond to locations in the computer’s memory Each variable has a name, type, size and value Whenever a value is placed in a memory location, it replaces the value previously stored in that location. The Previous value is destroyed When a value is read from a memory location, the process is nondestructive, meaning that the value in a memory is not changed
Pemrograman VisualMinggu …2… Page 18 Memory locations after an addition operation
Pemrograman VisualMinggu …2… Page 20 Precedence of Arithmetic Operator
Pemrograman VisualMinggu …2… Page 21 Example Precedence of Arithmetic Operator
Pemrograman VisualMinggu …2… Page 22 Summary Arithmetic Binary operators operate on two operands; unary operator operate on one operand. The Mod operator yields the remainder after division. Arithmetic expressions in visual basic must be written in straight-line form to enter programs into a computer. Parentheses are used in visual basic expressions in the same manner as in algebraic expressions. Visual basic applies the operators in arithmetic expressions in a precise sequence, which is determine by the rule of the operator precedence If an expression contains multiple operator with the same precedence, the order in which the operators are applied is determined by their associability. In VB, all binary operators associate from left to right.
Pemrograman VisualMinggu …2… Page 23 Equality and Operational Operators
Pemrograman VisualMinggu …2… Page 24 Comparison with equality and relational operators
Pemrograman VisualMinggu …2… Page 25 Summary Equality and Operational Operators Visual Basic’s If… Then statement allows a program to make a decision based on the truth or falsity of a condition. If the condition is true, the statement in the body of the If… Then statement executes. If the condition is false, the body statement does not execute. Conditions in If… Then statements can be formed by using the equality operators and relational operators. Equality operators and relational operators are also called comparison operators. Relational and equality operators have the same level of precedence and associate from left to right
Pemrograman VisualMinggu …2… Page 27 Message dialog to display message (Continued …) Visual Basic provides class MessageBox for creating message dialogs Line 10 calls the Sqrt method of the Math class to compute the square root of 2. The value returned is a floating-point number, so we declare the variable root as type Double. Note the use of spacing in lines 13–14 of Fig. 3.28. To improve readability, long statements may be split over several lines using the line-continuation character, _. Line 13 uses the line-continuation character to indicate that line 14 is a continuation of the pre-ceding line. Lines 13–14 (Fig. 3.28) call method Show of class MessageBox. This method takes a comma-separated argument list. The first argument is the string that is displayed in the message dialog. The second argument is the string that is displayed in the message dialog’s title bar.
Pemrograman VisualMinggu …2… Page 28 Analyzing the MessageBox
Pemrograman VisualMinggu …2… Page 29 Summary Message dialog to display message Message dialogs are windows that display messages to the user. Visual Basic provides the class MessageBox for creating message dialogs. The.NET Framework Class Library organizes groups of related classes into namespaces. The System.Windows.Forms namespace contains windows-related classes (i.e., forms and dialogs) that help you define graphical user interfaces (GUIs) for their applications. GUI components facilitate data entry by the user and the formatting and presenting of data outputs to the user. An Imports statement indicates that a program uses the features provided by a specific namespace, such as System.Windows.Forms. To improve readability, long statements may be split over several lines with the line-continuation character ( _ ). Although a single statement can contain as many line-continuation characters as necessary, at least one whitespace character must precede each line-continuation character. Assemblies that contain compiled classes for reuse in applications are located in files with a.dll (dynamic link library) extension.
Your consent to our cookies if you continue to use this website.