954,551 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

String to object identifier

Hello all!
Firstly, sorry, it's been a while since I've been programming and I'm relatively new to VB

My question is this;
I want to change the number in an object identifier to what ever number the program picks at random.
Roulette, 37 spots on the wheel, random number 1-37, and there are 37 images which can be displayed in accordance to that.
Now, to save myself from writing out 37 If commands, I'd like to know if there is a way to get around that.
the object identifiers are W1, W2, W3, W4.......W37


[
Dim digx As Integer = 2
Dim NUM As Integer
Dim WPos As String

Randomize()
NUM = Int(((4 + 1) - 1) * Rnd() + 1)

Me.DNUM.Text = NUM
Me.PWheel.BringToFront()

WPos = "W" & NUM
Me.TB.Text = WPos
]

(only doing 1-4 to keep it simple for now)

everything works there great so far. I can get the output i want being "w"x. But when trying to reference that string value to an object, ie [ me.WPos.BringToFront () ] it doesn't like that.

Any way to fix that?

johnovision27
Newbie Poster
2 posts since Feb 2010
Reputation Points: 10
Solved Threads: 0
 

Are you sure you are using Visual Basic 6.0? I'm almost ready to say that you need to be in the VB.NET forum and if you are using VB.NET, well then you will need to PM a mod to have your thread moved...

Good Luck

vb5prgrmr
Posting Virtuoso
1,912 posts since Mar 2009
Reputation Points: 156
Solved Threads: 296
 

it's VB 2008. I assumed it would be similar, but I'm pretty new to this.

johnovision27
Newbie Poster
2 posts since Feb 2010
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: