Generate Ramdom number : Ramdom « Development « ASP.Net






Generate Ramdom number

<%@ Page Language=VB Debug=true %>
<script runat=server>
Sub Page_Load(ByVal Sender as Object, ByVal E as EventArgs)
    Dim MyRandom as New Random
    lblMessage1.Text = "A number from 1 to 6: " _
        & MyRandom.Next(1, 7)
    lblMessage2.Text = "A number from -3 to 1: " _
        & MyRandom.Next(-3, 2)
    lblMessage3.Text = "A number from 1 to 100: " _
        & MyRandom.Next(1, 101)
    lblMessage4.Text = "A 1 or a 2: " _
        & MyRandom.Next(1, 3)
End Sub
</SCRIPT>
<HTML>
<HEAD>
<TITLE>Random Numbers Sample Page</TITLE>
</HEAD>
<BODY TEXT="black" LINK="darkred" VLINK="darkred" ALINK="red" LEFTMARGIN="40" TOPMARGIN="40">
<form runat="server">
<Font Face="Tahoma">
<asp:Label
    id="lblMessage1"
    runat="server"
    Font-Bold="True"
/>
<BR><BR>
<asp:Label
    id="lblMessage2"
    runat="server"
    Font-Bold="True"
/>
<BR><BR>
<asp:Label
    id="lblMessage3"
    runat="server"
    Font-Bold="True"
/>
<BR><BR>
<asp:Label
    id="lblMessage4"
    runat="server"
    Font-Bold="True"
/>
</Font>
</Form>
</BODY>
</HTML>
           
       








Related examples in the same category