3 Replies - 7152 Views - Last Post: 07 November 2006 - 05:17 PM Rate Topic: -----

#1 xiaoyin  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • 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.

can someone please help me with this?

Is This A Good Question/Topic? 0
  • +

Replies To: one dimensional array problem - assign help

#2 Jayman  Icon User is offline

  • Student of Life
  • member icon

Reputation: 418
  • View blog
  • 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"?
Was This Post Helpful? 0
  • +
  • -

#3 xiaoyin  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • 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
Was This Post Helpful? 0
  • +
  • -

#4 KeyWiz  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 8
  • View blog
  • Posts: 438
  • Joined: 26-October 06

Re: one dimensional array problem - assign help

Post icon  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.



Was This Post Helpful? 0
  • +
  • -

Page 1 of 1