Generate a random number

Straightforward script to generate a random number. Every time the Page loads a new random number will be generated and displayed in your browser by the label control 'lblRndNumber'.

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
'Declare Variables
Dim RandomGenerator As Random
Dim intRandomNumber As Integer

RandomGenerator = New Random()
'Pass in the inclusive min value and non-inclusive max value
'So in this script a value between 1 and 99 will be returned
intRandomNumber = RandomGenerator.Next(1, 100)

lblRndNumber.Text = intRandomNumber.ToString

End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Random Number</title>
</head>
<body>
<asp:Label ID="lblRndNumber" runat="server" Text="Label"></asp:Label>
</body>
</html>

Get the best ASP hosting with DiscountASP.NET - great value, money back guarantee.

Advertisements



MembersPro

MembersPro PayPal - ASP Membership software

Plug and play ASP membership script that integrates with PayPal to let you charge recurring membership fees.

Global ASP.NET Hosting Leader - Click Here