|
-
Sep 14th, 2012, 04:16 PM
#1
Thread Starter
Member
[RESOLVED] Help with variables
So I've been trying for TOO long with this now, i really need some help..
I'll try to explain..
I want to "Dim" a command, so that when i want to use the "command" (which is "button1.location" I just want to enter button =
I also want to take the text from a string and put it after "="
Example of how it looks like in my brain... :
Code:
Dim button as string = "button1.location"
Dim box as string = "box1.location"
button = box
This is so that i can create a private Sub and use the Call command instead of typing the same code.. There really should be some way to do it
Help....
Edit: What. The. Hell. Why did it just work.. Ignore the Newb.
Last edited by ErikJohansson; Sep 14th, 2012 at 04:19 PM.
-
Sep 14th, 2012, 04:23 PM
#2
Re: Help with variables
Something you should defiantly do, which I've suggested to you in the past is to turn option strict and explicit on. Because if you do want to get the location of a button or box, the variable type would be a point, not a string.
-
Sep 15th, 2012, 12:03 AM
#3
Re: Help with variables
In the future, I'd advise you state your problem instead of the solution you think might work. Your OP describes a solution, one that looks like something I'd advise against. I can't completely extrapolate from it what your problem is but it seems like something that can be solved in a clean manner with delegates.
-
Sep 15th, 2012, 12:44 AM
#4
Re: Help with variables
 Originally Posted by ErikJohansson
So I've been trying for TOO long with this now, i really need some help..
I'll try to explain..
I want to "Dim" a command, so that when i want to use the "command" (which is "button1.location" I just want to enter button =
I also want to take the text from a string and put it after "="
Example of how it looks like in my brain... :
Code:
Dim button as string = "button1.location"
Dim box as string = "box1.location"
button = box
This is so that i can create a private Sub and use the Call command instead of typing the same code.. There really should be some way to do it
Help....
Edit: What. The. Hell. Why did it just work.. Ignore the Newb.
By sayign it worked I take it that you actually mean it did not give you an error. You are assigning two strings then assigning one string value to the other which is perfectly fine but it would appear that you are trying to work with the property of an object namely Button.Location which of course is not a string and can not be used in such a way.
As mentioned in post number 2 you would have to define it as a Point and it takes 2 numeric values not a string.
-
Sep 16th, 2012, 02:55 AM
#5
Re: [RESOLVED] Help with variables
Have a look at this page, it explains .Location
You do not need
Code:
Dim button As String = "button1.Location
you need something more like
Code:
Button1.Location = New Point(100, 200)
The numbers 100 and 200 are pixels measured from the Left and Top respectively of the container that the button is in. This will probably be the form itself in this case.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|