Walk Lightly on this PLANET and yet leave such a FOOTPRINT that cannot be erased for thousands of Years..!!!
Visit Codstech for Cyber Security related Posts !

Visitors

Saturday, May 28, 2011

VB-14 : Making decision with Select Case

Select Case structure is an alternative to IF..THEN......ElseIF...for selectively executing one block of statements from among multiple blocks of statements.
You can add any number of ElseIF clauses as you need to provide alternative choices.A better way to choose between several alternatives is the Select Case statement as in the example given below:


Let there be a text field in which the user is supposed to enter the choices from a range of options given.


Enter any fruit from one of the following choices : Mango,apple,banana,orange and pineapple.


A)   Property :
Comman Button : NAME – Command1,CAPTION-Submit
Text Box          :NAME-text1,TEXT-(Blank)




B)   Attaching Code to the Object :
Private Sub Command1_Click()
Select Case Text1.Text
Case "Mango"
MsgBox "Mango is in green colour"
Case "Banana"
MsgBox "Banana is in yellow colour"
Case "Orange"
MsgBox "Orange is in orange colour"
Case "Apple"
MsgBox "Apple is in red colour"
Case "Pineapple"
MsgBox "Pineapple is in cream colour"
Case Else
MsgBox "The fruit you choose is not in the list"
End Select
End Sub

 ========================================================================
Back to Home   &  VB

No comments: