.:: Jasa Membuat Aplikasi Website,Desktop,Android Order Now..!! | | Order Now..!! Jasa Membuat Project Arduino,Robotic,Print 3D ::.

Lesson 6 - Controlling Program Flow

0 komentar


بِسْــــــــــــــــمِ اﷲِالرَّحْمَنِ اارَّحِيم
bismillaahirrahmaanirrahiim

السَّلاَمُ عَلَيْكُمْ وَرَحْمَةُ اللهِ وَبَرَكَاتُهُ
Assalamu'alaikum warahmatullahi wabarakatuh

In previous lessons, we have learned how to create Visual Basic code that can  accept input from the user and display the output without controlling the program flow. In this chapter, you will learn how to crreate VB code that can make decision when it process input from the user, and control the program flow in the process. Decision making process is an important part of programming because it can help to solve practical problems intelligently so that it can provide useful output or feedback to the user. For example, we can write a  program that can ask the computer to perform certain task until a certain condition is met.    

7.1  Conditional Operators

To control the VB program flow, we can use various conditional operators. Basically, they resemble mathematical  operators. Conditional operators are very powerful tools, they let the VB program compare data values and then decide what action to take, whether to execute a program or terminate the program and more. These operators are shown in Table 7.1.
7.2  Logical Operators

In addition to conditional operators, there are a few logical operators which offer added power to the VB programs. There are shown in Table 7.2.

Table 7.1: Conditional Operators


Operator
Meaning


=
Equal to


>
More than


<
Less Than


>=
More than and equal


<=
Less than and equal


<>
Not Equal to

Table 7.2:Logical Operators
Operator
Meaning
And
Both sides must be true
or
One side or other must be true
Xor
One side or other must be true but not both
Not
Negates truth

You can also compare strings with the above operators. However, there are certain rules to follows: Upper case letters are less than lowercase letters, "A"<"B"<"C"<"D".......<"Z" and number are less than letters.

7.3  Using  If.....Then.....Else  Statements  with Operators

To effectively control the VB program flow, we shall use If...Then...Else statement together with the conditional operators and logical operators.
The general format for the if...then...else statement is

    If  conditions Then

    VB expressions

    Else

    VB expressions

    End If

* any If..Then..Else statement must end with End If. Sometime it is not necessary to use Else.

Example:

  Private Sub OK_Click()

    firstnum=Val(usernum1.Text)

    secondnum=Val(usernum2.Text)

    If total=firstnum+secondnum And Val(sum.Text)<>0 Then

    correct.Visible = True
   wrong.Visible = False
  Else
    correct.Visible = False
    wrong.Visible = True
  End If

  End Sub

Update Contact :
No Wa/Telepon (puat) : 085267792168
No Wa/Telepon (fajar) : 085369237896
Email : Fajarudinsidik@gmail.com
NB :: Bila Sobat tertarik Ingin membuat software, membeli software, membeli source code, membeli hardware elektronika untuk kepentingan Perusahaan maupun Tugas Akhir (TA/SKRIPSI), Insyaallah Saya siap membantu, untuk Respon Cepat dapat menghubungi kami, melalui :

No Wa/Telepon (puat) : 085267792168
No Wa/Telepon (fajar) : 085369237896
Email: Fajarudinsidik@gmail.com


atau Kirimkan Private messanger melalui email dengan klik tombol order dibawah ini :

ٱلْحَمْدُ لِلَّهِ رَبِّ ٱلْعَٰلَمِين
Alhamdulilah hirobil alamin

وَ السَّلاَمُ عَلَيْكُمْ وَرَحْمَةُ اللهِ وَبَرَكَاتُهُ
wassalamualaikum warahmatullahi wabarakatuh


Artikel Lesson 6 - Controlling Program Flow, Diterbitkan oleh scodeaplikasi pada Selasa, 31 Januari 2012. Semoga artikel ini dapat menambah wawasan Anda. Website ini dipost dari beberapa sumber, bisa cek disini sumber, Sobat diperbolehkan mengcopy paste / menyebar luaskan artikel ini, karena segala yang dipost di public adalah milik public. Bila Sobat tertarik Ingin membuat software, membeli software, membeli source code ,Dengan Cara menghubungi saya Ke Email: Fajarudinsidik@gmail.com, atau No Hp/WA : (fajar) : 085369237896, (puat) : 085267792168.

Tawk.to