1'Author: 2' Satya Sudha K (ksathyasudha@novell.com) 3' 4' (C) 2005 Novell, Inc. 5 6' Testing whether all kinds of primitive types work well as 'Select' expression 7' Testing the case clauses like '<relational op> X' 8Option Strict Off 9 10Imports System 11 12Module ConditionalStatementsC 13 14 Function Main() As Integer 15 Dim errMsg As String = "" 16 Dim numMatches As Integer = 0 17 18 Dim a As Byte = 12 19 Select Case a 20 Case Is < 11 21 errMsg = errMsg & "#A1 Case statement not working with Select Expression of type byte " & vbCrLf 22 Case Is >= 12 23 numMatches += 1 24 Console.WriteLine("Byte") 25 Case 5 To 16 26 errMsg = errMsg & "#A1 Case statement not working with Select Expression of type byte" & vbCrLf 27 End Select 28 29 Dim b As Short = 234 30 Select Case b 31 Case Is <= 23 32 errMsg = errMsg & "#A2 Case statement not working with Select Expression of type Short" & vbCrLf 33 Case Is = 200 34 errMsg = errMsg & "#A2 Case statement not working with Select Expression of type Short" & vbCrLf 35 Case Is <> 24 36 numMatches += 1 37 Console.WriteLine("Short") 38 End Select 39 40 Dim c As Integer = 45 41 Select Case c 42 Case Is < 23 43 errMsg = errMsg & "#A3 Case statement not working with Select Expression of type Integer" & vbCrLf 44 Case Is <= 44 45 errMsg = errMsg & "#A3 Case statement not working with Select Expression of type Integer" & vbCrLf 46 End Select 47 48 Dim d As Long = 465 49 Select Case d 50 Case Is >= 480 51 errMsg = errMsg & "#A4 Case statement not working with Select Expression of type Long" & vbCrLf 52 Case Else 53 numMatches += 1 54 Console.WriteLine("Long") 55 End Select 56 57 Dim e As Decimal = 234232 58 Select Case e 59 Case 12 To 34 60 errMsg = errMsg & "#A5 Case statement not working with Select Expression of type Decimal" & vbCrLf 61 Case Is >= 200 62 numMatches += 1 63 Console.WriteLine("Decimal") 64 End Select 65 66 Dim f As Single = 23.5 67 Select Case f 68 Case Is <= 23.6 69 numMatches += 1 70 Console.WriteLine("Single") 71 Case Is = 24 72 errMsg = errMsg & "#A6 Case statement not working with Select Expression of type Single" & vbCrLf 73 End Select 74 75 Dim g As Double = 1.9 76 Select Case g 77 Case Is > 34 78 errMsg = errMsg & "#A7 Case statement not working with Select Expression of type double" & vbCrLf 79 Case Is < 20 80 numMatches += 1 81 Console.WriteLine("Double") 82 End Select 83 84 Dim h As String = "Sudha" 85 Select Case h 86 Case Is <> "Satya" 87 numMatches += 1 88 Console.WriteLine("String") 89 Case Else 90 errMsg = errMsg & "#A8 Case statement not working with Select Expression of type String" & vbCrLf 91 End Select 92 93 Dim i As Char = "4" 94 Select Case i 95 Case Is < "g" 96 Console.WriteLine("Char") 97 numMatches += 1 98 Case Else 99 errMsg = errMsg & "#A9 Case statement not working with Select Expression of type Char" & vbCrLf 100 End Select 101 102 Dim j As Object = 45.6 103 Select Case j 104 Case 23 To 90 105 numMatches += 1 106 Console.WriteLine("Object") 107 Case 45, 23, 234 108 errMsg = errMsg & "#A10 Case statement not working with Select Expression of type Object" & vbCrLf 109 End Select 110 111 Dim k As Date = #4/23/2005# 112 Select Case k 113 Case Is = #1/1/1998# 114 errMsg = errMsg & "#A11 Case statement not working with Select Expression of type DateTime" & vbCrLf 115 Case Is >= #1/1/2002# 116 numMatches += 1 117 Console.WriteLine("DateTime") 118 Case Is <= #2/11/2006# 119 errMsg = errMsg & "#A11 Case statement not working with Select Expression of type DateTime" & vbCrLf 120 End Select 121 122 If (errMsg <> "") Then 123 Throw New Exception(errMsg) 124 End If 125 If numMatches <> 10 Then 126 Throw New Exception("select-case statements not working properly") 127 End If 128 End Function 129 130End Module 131