ASP.NET IF...ElseIf...End IF ใช้ตรวจสอบเงื่อนไขกรณีที่เป็นจริงได้หลายกรณี
Syntax
If Condition1 Then
Statement ElseIF Condition2 Then
Statement ElseIF Condition3 Then
Statement ElseIF Condition4 Then
Statement Else
Statement End If
IIElseIFElseEndIF.aspx
<%@ Page Language="VB" %>
<script runat="server">
Sub Page_Load(sender As Object, e As EventArgs)
IF Now.Day = 10 Then
Me.lblText1.Text = "Now Day = 10-11-2008 (DD-MM-YYY)"
ElseIF Now.Day = 11 Then
Me.lblText1.Text = "Now Day = 11-11-2008 (DD-MM-YYY)"
ElseIF Now.Day = 12 Then
Me.lblText1.Text = "Now Day = 12-11-2008 (DD-MM-YYY)"
ElseIF Now.Day = 13 Then
Me.lblText1.Text = "Now Day = 13-11-2008 (DD-MM-YYY)"
ElseIF Now.Day = 14 Then
Me.lblText1.Text = "Now Day = 14-11-2008 (DD-MM-YYY)"
Else
Me.lblText1.Text = "Now Day = " & Format(Now.Date,"dd-M-yyyy")
End IF
End Sub
</script>
<html>
<head>
</head>
<body>
<form runat="server">
<asp:Label id="lblText1" runat="server"></asp:Label><br />
</form>
</body>
</html>