I was trying to create a random image generator. I'm using visual web dev
express with 2.0 framework.
On the web form page (mypage.aspx), I have an image control:
<asp:Image ID="Image1" runat="server" />
On the codebehind, (mypage.aspx.vb), I have this code when a button is
clicked:
Dim imagegen() As String
Dim x As Short
x = CShort(Rnd() * 15)
imagegen(0) = "../images/ticketimages/atlascow.jpg"
imagegen(1) = "../images/ticketimages/carpool.bmp"
imagegen(2) = "../images/ticketimages/catsquirrel.jpg"
imagegen(3) = "../images/ticketimages/creature.jpeg"
imagegen(4) = "../images/ticketimages/fitnessescalator.bmp"
imagegen(5) = "../images/ticketimages/frogcat.jpg"
imagegen(6) = "../images/ticketimages/helicopter.jpg"
imagegen(7) = "../images/ticketimages/highheelbike.bmp"
imagegen(8) = "../images/ticketimages/kisspandas.jpg"
imagegen(9) = "../images/ticketimages/libertylegs.jpg"
imagegen(10) = "../images/ticketimages/portapotty.bmp"
imagegen(11) = "../images/ticketimages/rabbitfingers.jpg"
imagegen(12) = "../images/ticketimages/santaplane.bmp"
imagegen(13) = "../images/ticketimages/sharkattack.jpg"
imagegen(14) = "../images/ticketimages/swissarmyant.jpg"
imagegen(15) = "../images/ticketimages/whaletail.jpg"
Image1.ImageUrl = imagegen(x)
When I tested the code, I got this error:
Server Error in '/' Application.
--------------------------------------------------------------------------------
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object.
Source Error:
Line 346: Dim x As Short
Line 347: x = CShort(Rnd() * 15)
Line 348: imagegen(0) = "../images/ticketimages/atlascow.jpg"
Line 349: imagegen(1) = "../images/ticketimages/carpool.bmp"
Line 350: imagegen(2) = "../images/ticketimages/catsquirrel.jpg"
Source File: E:\hhsinternal\Tickets\problem.aspx.vb Line: 348
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an
object.]
problem.btnReportProblem_Click(Object sender, EventArgs e) in
E:\hhsinternal\Tickets\problem.aspx.vb:348
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105
System.Web.UI.WebControls.Button.RaisePostBackEven t(String eventArgument)
+78
System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String
eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +33
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5670
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50215.44; ASP.NET
Version:2.0.50215.44
I'm a newbie with asp.net and vb.net. I've come a long ways but it seems
i've got a very long ways to go before I've got a clear understanding of
most of this stuff.
Thanks for the help!
Jim 2 2870
You have not defined the size of the array, therefore imagegen(0) does not
exist.
"Jim in Arizona" <ti*******@hotmail.com> wrote in message
news:uU**************@TK2MSFTNGP12.phx.gbl... I was trying to create a random image generator. I'm using visual web dev express with 2.0 framework.
On the web form page (mypage.aspx), I have an image control:
<asp:Image ID="Image1" runat="server" />
On the codebehind, (mypage.aspx.vb), I have this code when a button is clicked:
Dim imagegen() As String Dim x As Short
x = CShort(Rnd() * 15)
imagegen(0) = "../images/ticketimages/atlascow.jpg" imagegen(1) = "../images/ticketimages/carpool.bmp" imagegen(2) = "../images/ticketimages/catsquirrel.jpg" imagegen(3) = "../images/ticketimages/creature.jpeg" imagegen(4) = "../images/ticketimages/fitnessescalator.bmp" imagegen(5) = "../images/ticketimages/frogcat.jpg" imagegen(6) = "../images/ticketimages/helicopter.jpg" imagegen(7) = "../images/ticketimages/highheelbike.bmp" imagegen(8) = "../images/ticketimages/kisspandas.jpg" imagegen(9) = "../images/ticketimages/libertylegs.jpg" imagegen(10) = "../images/ticketimages/portapotty.bmp" imagegen(11) = "../images/ticketimages/rabbitfingers.jpg" imagegen(12) = "../images/ticketimages/santaplane.bmp" imagegen(13) = "../images/ticketimages/sharkattack.jpg" imagegen(14) = "../images/ticketimages/swissarmyant.jpg" imagegen(15) = "../images/ticketimages/whaletail.jpg"
Image1.ImageUrl = imagegen(x)
When I tested the code, I got this error:
Server Error in '/' Application. --------------------------------------------------------------------------------
Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 346: Dim x As Short Line 347: x = CShort(Rnd() * 15) Line 348: imagegen(0) = "../images/ticketimages/atlascow.jpg" Line 349: imagegen(1) = "../images/ticketimages/carpool.bmp" Line 350: imagegen(2) = "../images/ticketimages/catsquirrel.jpg"
Source File: E:\hhsinternal\Tickets\problem.aspx.vb Line: 348
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an object.] problem.btnReportProblem_Click(Object sender, EventArgs e) in E:\hhsinternal\Tickets\problem.aspx.vb:348 System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105 System.Web.UI.WebControls.Button.RaisePostBackEven t(String eventArgument) +78
System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String eventArgument) +7 System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler sourceControl, String eventArgument) +11 System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +33 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5670
-------------------------------------------------------------------------------- Version Information: Microsoft .NET Framework Version:2.0.50215.44; ASP.NET Version:2.0.50215.44
I'm a newbie with asp.net and vb.net. I've come a long ways but it seems i've got a very long ways to go before I've got a clear understanding of most of this stuff.
Thanks for the help!
Jim
Yep. That was it exactly!
Thanks!
Jim
"Peter Rilling" <pe***@nospam.rilling.net> wrote in message
news:OQ**************@TK2MSFTNGP09.phx.gbl... You have not defined the size of the array, therefore imagegen(0) does not exist.
"Jim in Arizona" <ti*******@hotmail.com> wrote in message news:uU**************@TK2MSFTNGP12.phx.gbl...I was trying to create a random image generator. I'm using visual web dev express with 2.0 framework.
On the web form page (mypage.aspx), I have an image control:
<asp:Image ID="Image1" runat="server" />
On the codebehind, (mypage.aspx.vb), I have this code when a button is clicked:
Dim imagegen() As String Dim x As Short
x = CShort(Rnd() * 15)
imagegen(0) = "../images/ticketimages/atlascow.jpg" imagegen(1) = "../images/ticketimages/carpool.bmp" imagegen(2) = "../images/ticketimages/catsquirrel.jpg" imagegen(3) = "../images/ticketimages/creature.jpeg" imagegen(4) = "../images/ticketimages/fitnessescalator.bmp" imagegen(5) = "../images/ticketimages/frogcat.jpg" imagegen(6) = "../images/ticketimages/helicopter.jpg" imagegen(7) = "../images/ticketimages/highheelbike.bmp" imagegen(8) = "../images/ticketimages/kisspandas.jpg" imagegen(9) = "../images/ticketimages/libertylegs.jpg" imagegen(10) = "../images/ticketimages/portapotty.bmp" imagegen(11) = "../images/ticketimages/rabbitfingers.jpg" imagegen(12) = "../images/ticketimages/santaplane.bmp" imagegen(13) = "../images/ticketimages/sharkattack.jpg" imagegen(14) = "../images/ticketimages/swissarmyant.jpg" imagegen(15) = "../images/ticketimages/whaletail.jpg"
Image1.ImageUrl = imagegen(x)
When I tested the code, I got this error:
Server Error in '/' Application. --------------------------------------------------------------------------------
Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 346: Dim x As Short Line 347: x = CShort(Rnd() * 15) Line 348: imagegen(0) = "../images/ticketimages/atlascow.jpg" Line 349: imagegen(1) = "../images/ticketimages/carpool.bmp" Line 350: imagegen(2) = "../images/ticketimages/catsquirrel.jpg"
Source File: E:\hhsinternal\Tickets\problem.aspx.vb Line: 348
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an object.] problem.btnReportProblem_Click(Object sender, EventArgs e) in E:\hhsinternal\Tickets\problem.aspx.vb:348 System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105 System.Web.UI.WebControls.Button.RaisePostBackEven t(String eventArgument) +78
System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String eventArgument) +7 System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler sourceControl, String eventArgument) +11 System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +33 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5670
-------------------------------------------------------------------------------- Version Information: Microsoft .NET Framework Version:2.0.50215.44; ASP.NET Version:2.0.50215.44
I'm a newbie with asp.net and vb.net. I've come a long ways but it seems i've got a very long ways to go before I've got a clear understanding of most of this stuff.
Thanks for the help!
Jim
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Phil Powell |
last post by:
I created a page that will be doing image resizing and manipulation,
which seems to work (using GD library). However, upon returning to
the page where the image has been changed, I still see the...
|
by: Ioannis Vranos |
last post by:
I want to create some random numbers for encryption purposes, and i wonder
if the following scheme makes it more hard to guess the underneath number
generation pattern, than the plain use of...
|
by: Dimos |
last post by:
Hello All,
I need some help with random number generation. What I
need exactly is:
To create a few thousand numbers, decimal and
integers, between 5 and 90,
and then to export them as a...
|
by: tshad |
last post by:
I am trying to set up an Image authorization where you type in the value
that is in a picture to log on to our site.
I found a program that is supposed to do it, but it doesn't seem to work.
...
|
by: skip |
last post by:
Is there a module out there that will generate an image with a random text
string such as the confirmation images you see on various websites? I'm
thinking I'm going to have to add that to the...
|
by: gagan.singh.arora |
last post by:
Hi there.
I want to generate random numbers with a given probability, say 80%
even and 20% odd. Is it possible to implement such an algorithm in C?
|
by: chico_yallin |
last post by:
I just wana make a random id number based on4 digits-for examples??
Thanks in Advance
Ch.Yallin
|
by: jason.cipriani |
last post by:
I am looking for a random number generator implementation with the
following requirements:
- Thread-safe, re-entrant.
- Produces consistently reproducible sequences of psuedo-random
numbers...
|
by: Fan924 |
last post by:
How do I add random number generation to this background image slide
show? Everything I try kills if. TIA
_____________________________________
<html>
<head>
<meta http-equiv="Content-Type"...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |