Upload
ade-hermawan
View
220
Download
0
Embed Size (px)
DESCRIPTION
des
Citation preview
Modul ke:FakultasProgram StudiPEMOGRAMAN VISUAL CLIENT SERVERForm Variable, Data Type, Operator, Condition, IterationHariesa B.P, ST, MM04FASILKOMSistem Informasi
Module OverviewDeclaring Variable and assigning valuesData TypeOperatorConditionIteration
Variables
VariablesA variable represents a named location in memory for piece of data. An application can access a piece of data by using the variable it has been assigned to.A varible has the following six facets:Name : Unique identifier that refer to the variable in codeAddress : Memory location of the variable.Data type : Type and size of data that the variable can storeValue : Value at the address of the variable.Scope : Define area of code that can access and use the variable.Lifetime : Period of time that a variable is valid and available for useExamples of variable As a counter for loop structureAs Temporary storage for property valuesAs a container to store a value that was return from a function
Data Type
Data Type
Declaring & Assigning VariablesNote :C# is case sensitive. Variable MyData is not the same with myData
Declaring & Assigning Variables
What is variable scopeVariable can have one of the following level of scope BlockProcedureClassNamespace
What is variable scope
Converting a Value to Different Data TypeThere are two type of conversions :Implicit conversion. Automatically performed by the common language runtime (CLR) on operations that are guaranteed to succeedExplicit conversion. Require to write code to perform a conversion that otherwise could lose information or procedure an error.
Converting a Value to Different Data Type
Implicit Conversion
Explicit ConversationClass for conversation :System.Convert
Operators
Operators Assignment
Decision Statement
Using One Way If Statement
Using ? Or If Statement
Using ? Or If Statement
Using Multiple Outcome If Statement
Using the Switch Statement
Using the Switch Statement
Guideline for Choosing a Decision Construct
Practice Right click on the solution name, Add new project, click visual C#, click windows, click windows form, give the project name with latihan4Right click on project name, click set as startup projectCreate a New Form and name as DecisionForm
FieldDescriptionNameDecisionFormTextdecision Form AplikasiStartPositionCenterScreen
Decision FormAdd 2 textbox, 2 label and 3 button
Properties Label
FieldDescriptionNamelabel1TextVariabel 1Name Label2TextVariabel 2
Properties TextBox
FieldDescriptionNametbVar1Name tbVar2
Properties Button
FieldDescriptionNamebtnIfTextGO IfName btnItenaryTextGO ?NamebtnSwitchTextGo Switch
Code For btnIf
Code for btnItenarySet as to run for first time then click F5
Code for btnSwitch
Iteration Statement
Type Of Iteration Statement
While Statement
Do Loop Statement
For Statement
Break & Continue Statment
PracticeCreate a New Form and name as IterationForm
FieldDescriptionNameIterationFormTextIteration Form AplikasiStartPositionCenterScreen
Layout Iteration FormAdd 2 Label, 2 textbox and 3 Button
Properties Label
FieldDescriptionNamelabel1TextNilai AwalNamelabel2TextBatas AKhir
Properties TextBox
FieldDescriptionNametextbox1 -> tbNilaiAwalNametextbox2 -> tbCounter
Properties Button
FieldDescriptionNamebtnWhileTextWhileName btnDoTextDoNamebtnForTextFor
Code For btnWhile
Code For btnDo
Code for btnForSet as the Form for run, then click F5
ReferenceMCT 10266MCT 2546netIndonesia.netMSDN
Terima Kasih