Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...This is easily the most helpful website I've ever used, and this is the best forum with the quickest response time bar none...."

Geography

Where in the world do Tek-Tips members come from?

How to assign a value to a location.x of a picturebox programmatically?Helpful Member! 

Antzelinaki (Programmer)
22 Jun 12 12:29
Hello!!!
I have created an array of pictureboxes named pbs. Public pbs(8) As PictureBox
And the what I want to do is to assign a different specific value for Location.X and Location.Y programmatically for each element. x,y are variables that change their values for each element programmatically.

for example

for i=0 to 7
pbs(i).Location.X = x
pbs(i).Location.Y = y
next i

Unfortunately I am getting this error Expression is a value and therefore cannot be the target of an assignment.
before to run it. So, is there a way to do it and how??? Any help will be much appreciated.
Helpful Member!  jebenson (TechnicalUser)
25 Jun 12 22:44
Use the Left and Top properties to set the X and Y, respectively:

for i=0 to 7
pbs(i).Left = x
pbs(i).Top = y
next i

0,0 is the upper-left corner of the container (e.g., form, panel, tab control, etc.)

You can also do:

for i=0 to 7
pbs(i).Location = New Point(x, y)
next i

I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day!

Antzelinaki (Programmer)
2 Jul 12 12:16
Thank you so much jebenson. The second way works for me :)

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close