1 / 8

Estructura de Selección en Visual Basic

Estructura de Selección en Visual Basic. COMP 215. Definición. La estructura de selección la utilizamos cuando necesitamos programar el computador para que, dependiendo del cumplimiento o no de ciertas condiciones dentro del programa, se ejecuten o no instrucciones. If Blocks.

Download Presentation

Estructura de Selección en Visual Basic

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Estructura de Selección en Visual Basic COMP 215

  2. Definición • La estructura de selección la utilizamos cuando necesitamos programar el computador para que, dependiendo del cumplimiento o no de ciertas condiciones dentro del programa, se ejecuten o no instrucciones.

  3. If Blocks • If condition Then action1Else action2End If

  4. Flowchart general N Is the condition true? T Execute action2 Execute action1

  5. ElseIf clauses If condition1 Then action1ElseIf condition2 Then action2ElseIf condition3 Then action3Else action4 End If

  6. EjemploprogramaciónElseIf Public Class Form1 Private Sub Button1_Click(ByVal sender AsSystem.Object, ByVal e AsSystem.EventArgs) Handles Button1.Click DimgpaAs Double Dim honors As String gpa = CDbl(TextBox1.Text) If gpa >= 3.9 Then honors = "summa cum laude..." ElseIfgpa >= 3.6 Then honors = "magna cum laude..." ElseIfgpa >= 3.3 Then honors = "cum laude..." ElseIfgpa >= 2.0 Then honors = "........." Else honors = "You don't graduated..." End If TextBox2.Text = gpa & " " & honors End Sub End Class

  7. Select Case Block Select Case selectorCasevalueList 1 action1CasevalueList 2 action2CaseElse action of last resortEnd Select

  8. EjemploprogramaciónSelect Case Public Class Form1 Private Sub Button1_Click(ByVal sender AsSystem.Object, ByVal e AsSystem.EventArgs) Handles Button1.Click DimgpaAs Double Dim honors As String gpa = CDbl(TextBox1.Text) Select Case gpa Case Is >= 3.9 honors = "summa cum laude..." Case Is >=3.6 honors = "magna cum laude..." Case Is >= 3.3 honors = "cum laude..." Case Is >=2.0 honors = "........." Case Else honors = "You don't graduated..." End Select TextBox2.Text = gpa & " " & honors End Sub End Class

More Related