انت هنا الان : شبكة جامعة بابل > موقع الكلية > نظام التعليم الالكتروني > مشاهدة المحاضرة

Sixth Lecture : Conditional Statements (part II)

Share |
الكلية كلية هندسة المواد     القسم قسم البوليمرات والصناعات البتروكيمياوية     المرحلة 2
أستاذ المادة حسين محمد سلمان الشمري       09/12/2015 19:39:46
Sixth Lecture : Conditional Statements (part II)
Some Examples about the conditional statements:
Example1:Design a project to characterize the input symbol ? In this example we will use the conditional statement select case to write the codes:
1st Stage : Design Form
In this stage , we need some tools such as two command buttons , two labels and only one text box, as bellow:
3rd Stage: Write the Codes
The codes in the cmdTest (Test) :
Dim ch As Variant, stat As String
ch = txtChar.Text
Select Case ch
Case 0 To 9
stat = "The symbol is Digit"
Case "a" To "z", "A" To "Z"
stat = "The symbol is Letter"
Case "!", "@", "#", "$", "&"
stat = "Special Symbols"
Case Else
stat = "Unknown"
End Select
lblResult.Caption = stat
The form after running will be:



Example2: we will solve same problem in the previous example by using IF-statement as below :
Dim ch As Variant, stat As String
ch = txtChar.Text
If ch >= 0 And ch <= 9 Then
stat = "The symbol is Digit"
ElseIf (ch >= "a" And ch <= "z") Or (ch >= "A" And ch <= "Z") Then
stat = "The symbol is Letter"
ElseIf ch = "!" Or ch = "@" Or ch = "#" Or ch = "$" Or ch = "&" Then
stat = "Special Symbols"
Else
stat = "Unknown"
End If
lblResult.Caption = stat


المادة المعروضة اعلاه هي مدخل الى المحاضرة المرفوعة بواسطة استاذ(ة) المادة . وقد تبدو لك غير متكاملة . حيث يضع استاذ المادة في بعض الاحيان فقط الجزء الاول من المحاضرة من اجل الاطلاع على ما ستقوم بتحميله لاحقا . في نظام التعليم الالكتروني نوفر هذه الخدمة لكي نبقيك على اطلاع حول محتوى الملف الذي ستقوم بتحميله .
الرجوع الى لوحة التحكم