# one dimensional array problem - assign help

Page 1 of 1

## 3 Replies - 7403 Views - Last Post: 07 November 2006 - 05:17 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=20559&amp;s=98592f1730564779611afb4ffebde1db&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 xiaoyin

Reputation: 0
• Posts: 3
• Joined: 07-November 06

# one dimensional array problem - assign help

Posted 07 November 2006 - 05:06 AM

okay i have to program the game "Wheel of Fortune" (base on the TV show) for my ipt assign using VB2005 Express Edition
for the wheel part, i decided to use a label and then generate random picture with number values on it from a image list. the code for this part is as follow:
```Dim j As Integer = 0
'randomly generate a pic with the money value on it
Randomize()
j = Int(Rnd() * 12)

```

after i generated teh random number, i find the image that's assigned to that number and also the value that i am assigned to a array in the module of my program. codes are as follow:
```'find the value assign to the array that's link to the image list... i think
picWheel.Image = imlMoney.Images(j)
Money = MoneyValue(j)
lblDisplay.Text = MoneyValue(j)

```

as for the assign value part in the module:
```
Public MoneyValue(11) As Double
Public Sub SetValues()
MoneyValue(0) = 1
MoneyValue(1) = 50
MoneyValue(2) = 123
MoneyValue(3) = 160
MoneyValue(4) = 200
MoneyValue(5) = 240
MoneyValue(6) = 350
MoneyValue(7) = 393
MoneyValue(8) = 450
MoneyValue(9) = 600
MoneyValue(10) = 1000
MoneyValue(11) = PMoney
End Sub

```

for some unknown reason, every single time i generated a picture out, it return 0 as the value.

Is This A Good Question/Topic? 0

## Replies To: one dimensional array problem - assign help

### #2 Jayman

• Student of Life

Reputation: 419
• Posts: 9,532
• Joined: 26-December 05

## Re: one dimensional array problem - assign help

Posted 07 November 2006 - 08:32 AM

I'm not sure I understand exactly what you are saying, what do you mean by "every single time i generated a picture out"?

### #3 xiaoyin

Reputation: 0
• Posts: 3
• Joined: 07-November 06

## Re: one dimensional array problem - assign help

Posted 07 November 2006 - 03:50 PM

oh by "every single time i generated a picture out", i mean that whenever i clicked the button that generate a random picture out of the image list.

after i click the button, a random picture with a number on it suppose to pop up in a label. and then the same number would appear in a textbox... or i should said that the same number suppose to appear in a textbox. instead a "0" pop up every single time

### #4 KeyWiz

• D.I.C Regular

Reputation: 8
• Posts: 439
• Joined: 26-October 06

## Re: one dimensional array problem - assign help

Posted 07 November 2006 - 05:17 PM

I believe the problem is declaring j at the beginning of the code block. This will always reset it to 0. to Fix this declare the varriable before the form is loaded,
```Option Explicit

Public j as integer

private btnButton_Click()
'randomly generate a pic with the money value on it
Randomize()
j = Int(Rnd() * 12)
. . . . .

and so on.

```