Mega Code Archive

 
Categories / VisualBasic Script / Language Basics
 

Use string text as the select case statement control value

Function Price(Product As String) As Variant   Select Case Product     Case "Apples":  Price = 12.5     Case "Oranges": Price = 15     Case "Pears":   Price = 18     Case "Mangoes": Price = 25     Case Else:      Price = CVErr(xlErrNA)   End Select End Function Sub test()     MsgBox CStr(Price("Oranges")) End Sub