VB.NET & IF…Else…End IF - IF…Else…End IF : Conditionally executes a group of statements, depending on the value of an expression.
ShotDev Focus:
- VB.NET & IF…Else…End IF
Syntax
If condition [ Then ] [ statements ] [ Else [ elsestatements ] ] End If -or- If condition Then [ statements ] [ Else [ elsestatements ] ]
Example
IIElseEndIF.aspx
<%@ Page Language="VB" %> <script runat="server"> Sub Page_Load(sender As Object, e As EventArgs) '*** Current Date 22-Jun-2010 ***' IF Now.Day = 22 Then Me.lblText1.Text = "Now Day = 22-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> </html>
Screenshot