Select Case Demo : Select « Language Basics « VB.Net

Home
VB.Net
1.2D
2.Application
3.Class
4.Data Structure
5.Data Types
6.Database ADO.net
7.Development
8.Event
9.File Directory
10.Generics
11.GUI
12.Language Basics
13.LINQ
14.Network Remote
15.Security
16.Thread
17.Windows Presentation Foundation
18.Windows System
19.XML
20.XML LINQ
VB.Net Tutorial
VB.Net by API
VB.Net » Language Basics » SelectScreenshots 
Select Case Demo
Select Case Demo

Imports System

Public Class MainClass

    Shared Sub Main(ByVal args As String())

      Dim grade As Integer = ' one grade
      Dim aCount As Integer = ' number of As
      Dim bCount As Integer = ' number of Bs
      Dim cCount As Integer = ' number of Cs
      Dim dCount As Integer = ' number of Ds
      Dim fCount As Integer = ' number of Fs

      Console.Write("Enter a grade, -1 to quit: ")
      grade = Console.ReadLine()

      ' input and process grades
      While grade <> -1

         Select Case grade    ' determine which grade was input

            Case 100          ' student scored 100
               Console.WriteLine("Perfect Score!" & vbCrLf & _
                  "Letter grade: A" & vbCrLf)
               aCount += 1

            Case 90 To 99     ' student scored 90-99
               Console.WriteLine("Letter Grade: A" & vbCrLf)
               aCount += 1

            Case 80 To 89     ' student scored 80-89
               Console.WriteLine("Letter Grade: B" & vbCrLf)
               bCount += 1

            Case 70 To 79     ' student scored 70-79
               Console.WriteLine("Letter Grade: C" & vbCrLf)
               cCount += 1

            Case 60 To 69     ' student scored 60-69
               Console.WriteLine("Letter Grade: D" & vbCrLf)
               dCount += 1

               ' student scored or 10-59 (10 points for attendance)
            Case 010 To 59
               Console.WriteLine("Letter Grade: F" & vbCrLf)
               fCount += 1

            Case Else

               ' alert user that invalid grade was entered
               Console.WriteLine("Invalid Input. " & _
                  "Please enter a valid grade." & vbCrLf)
         End Select

         Console.Write("Enter a grade, -1 to quit: ")
         grade = Console.ReadLine()
      End While

      ' display count of each letter grade
      Console.WriteLine(vbCrLf & _
         "Totals for each letter grade are: " & vbCrLf & _
         "A: " & aCount & vbCrLf & "B: " & bCount _
         & vbCrLf & "C: " & cCount & vbCrLf & "D: " & _
         dCount & vbCrLf & "F: " & fCount)

    End Sub
    

End Class

           
       
Related examples in the same category
1.Select rangeSelect range
2.Select IntegerSelect Integer
3.Select with conditionSelect with condition
4.Select Integer ValueSelect Integer Value
5.Select with CompareSelect with Compare
6.Select String ValueSelect String Value
7.Select String Value: rangeSelect String Value: range
8.Select Else DemoSelect Else Demo
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.