ASP.NET Tutorial/Language Basics/Case

Материал из .Net Framework эксперт
Перейти к: навигация, поиск

Use Select case statement with integer type value (VB)

<%@ Page Language="VB" %>
<script runat="server">
   sub Page_Load(Sender as object, e as eventargs)
      dim intAge As integer = 7
      select Case intAge
         case "7"
            Response.Write("That"s a string!")
         case 7
            Response.Write("7")
         case <10
            Response.Write("less than 10")
      end select
   
   end sub   
</script>
<html><body>
</body></html>


Use Select Case statement with String type value (VB)

<%@ Page Language="VB" %>
<script runat="server">
   sub Page_Load(Sender as object, e as eventargs)
      dim strClockStatus As String
      strClockStatus = "AAA"   
      select Case strClockStatus
         case "AAA", "BBB", "CCC"
            Response.Write("A")
         case "DDD"
            Response.Write("B")
         case else
            Response.Write("C")
      end select
   end sub   
</script>
<html><body>
</body></html>