Archived

This topic is now archived and is closed to further replies.

Form location doesn't exist (Visual Basic)

This topic is 5268 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''m making a rather simple program as a break from my large game that probably won''t ever work properly, and I decided that it would be easier to use Visual Basic. So far everything has gone smoothly (which isn''t saying much because it''s hardly started) but I now am stuck. Thid tells me that I should be able to move the form at runtime with code, but when I make an attempt the location, left, and top members are nowhere to be found. Keep in mind that I have basically no expierience using Visual Basic but I''m fine with C/C++. Oh, and don''t tell me to rewrite the whole thing in some other language. I''ll just ignore you.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
quote:
Original post by cowsarenotevil
Oh, and don''t tell me to rewrite the whole thing in some other language. I''ll just ignore you.


friendly little bovine

Share this post


Link to post
Share on other sites
Heh, i''m just glad to hear someone being semi-rabid about using vb, instead of NOT using it.

On another note, here''s code copied and pasted from one of my vb 6.0 projects that moves its forms about.

frmLogin.Left = 2970
frmLogin.Top = 3120
frmLogin.Show

That''s actually done from within another form... but still.

Share this post


Link to post
Share on other sites
quote:
Original post by Anonymous Poster
quote:
Original post by cowsarenotevil
Oh, and don''t tell me to rewrite the whole thing in some other language. I''ll just ignore you.


friendly little bovine


I just don''t want the common reply of: "VB sucks and can''t do anything. You should reprogram the whole thing in C, even though it would take several hundred lines just to initialize the window the way you want it."

Share this post


Link to post
Share on other sites
That shouldn''t cause any problem. Me is just a reference to the form, the same as the form''s name is. At least, in VB 6. I''ve never used Vb.net, and am avoiding all .net arcitecture like the plague, till it''s been out a bit longer, and settled more.

While the me.(whatever) syntax will work, you probably aught to still look and try to figure out how to use the form''s name directly elsewhere, or else you''ll have a mell of a hess when you try to do anything to one form from another. (Such as displaying it. heh)

Share this post


Link to post
Share on other sites
You are actually better off using:
Form1.Move x, y, w, h
when you use left and top etc. they physically move the form to the left, and then to the top. Move does it in one operation.

Edit: when you are in the form's code itself the Form1. is implied (much like this-> in a class) so if you just specify left = x then it will know you are talking about the form.

[edited by - Sailorstick on July 8, 2003 7:18:09 PM]

Share this post


Link to post
Share on other sites
quote:
Original post by cowsarenotevil
But it says that form2.left isn''t a valid member of form2... I''m confused. I''m just trying to make it open a settings box when I right click... this is sad. I wonder if it would have been this difficault in C/C++


Are you sure you''re using Form1.Left not Form1.left? I think they''re case-sensitive.

Share this post


Link to post
Share on other sites
No, VB isn't case sensitive, and it will change the case to match the original anyway. I would use:
form2.Move x, y
Does this work? I don't know why left and top aren't working. Maybe they were removed in .NET in favour of Move?
BTW, make sure Form1 and Form2 are in the list of forms! Just making sure.
Edit: post some code

[edited by - Sailorstick on July 9, 2003 7:13:48 PM]

Share this post


Link to post
Share on other sites
To use "move," don't you need to know the original location? If so, how would I get it? Also, what if I want to show form2 when it's hidden? Also, if left and top were removed, why do they work when you access the form from within itself. I'm sure it's just some dumb thing I haven't learned yet.

EDIT: I can't try that stuff until I reboot windows and I'm installing some components in the background so I'll have to wait a few minutes to try this stuff.

EDIT2: OK, running windows now. What do you mean by "list of forms"?

[edited by - cowsarenotevil on July 9, 2003 7:25:20 PM]

[edited by - cowsarenotevil on July 9, 2003 7:41:48 PM]

Share this post


Link to post
Share on other sites
In the project window (right) there should be a folder called Forms and within that is the list of forms used in your app.
Move doesn''t require the current location if you are setting both x and y, but yes, if you want to only change one you need to know the other

Share this post


Link to post
Share on other sites
quote:
Original post by cowsarenotevil
Wait... I knw why it doesn''t work now. There aren''t default instances of the forms in .NET, so I have to make them myself. I think I might be able to figure it out now.

EDIT: article


[edited by - cowsarenotevil on July 9, 2003 8:31:41 PM]


That''s exactly what I was about to tell you... basically when you make a form in design mode in VB.NET and you give it a name.. that name is the name of the class, not the instance of the object... but I''m sure you''ve figured that out by now if you''ve read the article

Share this post


Link to post
Share on other sites
Hmm... I set it up so that each form would have a "definstance", but that instance is different from the "instance"(or whatever) that appears at runtime. So I figured that I''d set it to start with "Sub Main", but when I show the definstance, it immediately dissappears. This is so hopelessly confusing. I would completely give up on this .NET stuff if it weren''t for the cool transparency settings (that I utilize heavily)

Share this post


Link to post
Share on other sites