Tutorial Program 1 || DEV ++ STRUCTURE CONTROL (BRANCHING)
####STRUCTURE CONTROL (BRANCHING)
I. Purpose of Practicum
• Understand the events and properties in visual basic 6.0
• Know the environment and objects in visual basic
II. Basic theory
Visual Basic Control Structure (BRANCHING)
The control structure allows you to adjust the course of your program. If left un-checked by a control-flow statement, a program logic will run from left to right and from top to bottom. Only very simple programs can be written without a control-flow statement.
The CONTROL structure supported by Visual Basic is as follows
- If
If ... Then
Use an If ... Then structure to execute a statement conditionally. You can use single line syntax or multiple line syntax.
If condition Then statement
or
If condition then
statements
End If
The condition is usually a comparison, or an expression that results in a numerical value. Visual Basic interprets False as zero (0), and True as nonzero.
If ... Then ... Else
Use If ... Then ... Else to define multiple statement blocks to be executed by one based on qualified conditions.
If condition1 Then
[block statement-1] [ElseIf condition2 Then
[block statement-2]] ...
[Else
End If
[n-statement block]
Visual Basic will initially try condition1. If False, then Visual Basic will check the condition2, and so on until it finds a True condition to execute its statement block.
Example:
If JlhRec> 0 Then
Position = 1
Else
Position = 0
End If
- Select Case
Visual Basic provides a Select Case structure as an alternative to If ... Then ... Else. A Select Case statement has the same capability as If ... Then ... Else ..., but makes the code easier to read.
The Select Case structure works with a single experiment that is only evaluated once at the top of the structure. Visual Basic then compares the result of the expression with the value of each Case in the structure, if there is appropriate, will be executed the appropriate statement block.
Select Case expression that you tried
[Expression Case1
[block statement-1]] [Case expression2
[block statement-2]]
... [Case Else
[n-statement block]
End Select
III. Tools and materials
- CPU
- Monitor
- Keyboard
- Mouse
- Job Sheet Practicum
IV. Problems and Results of Experiments
Make a form like the following (the name of the object is customized itself):
Terms:
• When filling in test scores 1 and 2, the count button is active.
• After Average and Description are filled, the Count button disappears to change
Clear.
• Average = Exam Value 1 + Exam Value 2/2
• Description: If the Average is between 85 s / d 100 then Very Satisfactory If Average between 75 s / d 84 then Quite Satisfy If Average between 60 s / d 74 then Satisfactory
Besides Less Satisfactory
Trial View Results:
V. Analysis
Case Else is used to show the statement_else for execution if there is a discrepancy between the value in Condition and the n-Expression in some tests that have been done in the Case section.
VI. Conclusion
Use an If ... Then structure to execute a statement conditionally. You can use single line syntax or multiple line syntax.
Posted on Utopian.io - Rewarding Open Source Contributors
Your contribution cannot be approved because it does not follow the Utopian Rules.
You don't follow the template, your English is really hard to understand and you are using the wrong repository (why are you using one of mine?).
You can contact us on Discord.
[utopian-moderator]