'
'Select Case Statement
'
'Executes one of several groups of statements, depending on the value of an expression.
'
'Syntax
'
'Select Case testexpression
'[Case expressionlist-n
'[statements-n]]
'
'...
'
'
'[Case Else
'[elsestatements]]
'
'End Select
Option Explicit
'Example Select Case
Sub TestSelectCase()
Dim ProductPrice As Integer
ProductPrice = InputBox("What is the price of product?")
Select Case ProductPrice
Case Is <= 2000
MsgBox "Discount Percent:5% and discounted amount is: " & ProductPrice * 0.05
Case Is <= 5000
MsgBox "Discount Percent:10% and discounted amount is: " & ProductPrice * 0.1
Case Else
MsgBox "Discount Percent:15% and discounted amount is: " & ProductPrice * 0.15
End Select
End Sub
'Select Case Statement
'
'Executes one of several groups of statements, depending on the value of an expression.
'
'Syntax
'
'Select Case testexpression
'[Case expressionlist-n
'[statements-n]]
'
'...
'
'
'[Case Else
'[elsestatements]]
'
'End Select
Option Explicit
'Example Select Case
Sub TestSelectCase()
Dim ProductPrice As Integer
ProductPrice = InputBox("What is the price of product?")
Select Case ProductPrice
Case Is <= 2000
MsgBox "Discount Percent:5% and discounted amount is: " & ProductPrice * 0.05
Case Is <= 5000
MsgBox "Discount Percent:10% and discounted amount is: " & ProductPrice * 0.1
Case Else
MsgBox "Discount Percent:15% and discounted amount is: " & ProductPrice * 0.15
End Select
End Sub
No comments:
Post a Comment