Estructura de selecci n en visual basic
This presentation is the property of its rightful owner.
Sponsored Links
1 / 8

Estructura de Selección en Visual Basic PowerPoint PPT Presentation


  • 42 Views
  • Uploaded on
  • Presentation posted in: General

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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Estructura de selecci n en visual basic

Estructura de Selección en Visual Basic

COMP 215


Definici n

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

If Blocks

  • If condition Then action1Else action2End If


Flowchart general

Flowchart general

N

Is the condition true?

T

Execute action2

Execute action1


Elseif clauses

ElseIf clauses

If condition1 Then action1ElseIf condition2 Then action2ElseIf condition3 Then action3Else action4

End If


Ejemplo programaci n elseif

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


Select case block

Select Case Block

Select Case selectorCasevalueList 1 action1CasevalueList 2 action2CaseElse action of last resortEnd Select


Ejemplo programaci n select case

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


  • Login