VB.NET & IF…ElseIf…End IF - IF…ElseIf…End IF : Conditionally executes a group of statements, depending on the value of an expression.
ShotDev Focus:
- VB.NET & IF…ElseIf…End IF
Syntax
If condition [ Then ] [ statements ] [ ElseIf elseifcondition [ Then ] [ elseifstatements ] ] [ Else [ elsestatements ] ] End If -or- If condition Then [ statements ] [ Else [ elsestatements ] ]
Example
IIElseIFElseEndIF.aspx
<%@ Page Language="VB" %> <script runat="server"> Sub Page_Load(sender As Object, e As EventArgs) '*** Current Date 22-Jun-2010 ***' IF Now.Day = 21 Then Me.lblText1.Text = "Now Day = 21-06-2010 (DD-MM-YYY)" ElseIF Now.Day = 22 Then Me.lblText1.Text = "Now Day = 22-06-2010 (DD-MM-YYY)" ElseIF Now.Day = 23 Then Me.lblText1.Text = "Now Day = 23-06-2010 (DD-MM-YYY)" ElseIF Now.Day = 24 Then Me.lblText1.Text = "Now Day = 24-06-2010 (DD-MM-YYY)" ElseIF Now.Day = 25 Then Me.lblText1.Text = "Now Day = 25-06-2010 (DD-MM-YYY)" Else Me.lblText1.Text = "Now Day = " & Format(Now.Date,"dd-MM-yyyy") End IF End Sub </script> <html> <head> <title>ShotDev.Com Tutorial</title> </head> <body> <form runat="server"> <asp:Label id="lblText1" runat="server"></asp:Label><br /> </form> </body> </html>
Screenshot
1training…
…