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" "">

<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

<html xmlns="" >
<title>Random Number</title>
<asp:Label ID="lblRndNumber" runat="server" Text="Label"></asp:Label>

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



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