Elliot B. Posted December 9, 2015 Share Posted December 9, 2015 I am using Microsoft Visual Studio Community 2015. When I click on the blue Change link, I want it to open Form2 (below) in the center and on top of Form1 (above) Any ideas? I am a beginner - go easy on me! Link to comment Share on other sites More sharing options...
0 LimeMaster Posted December 9, 2015 Share Posted December 9, 2015 Try this, assuming I understood what you meant: Form2 frm2 = new Form2(); frm2.StartPosition = FormStartPosition.CenterParent; frm2.Show(); Link to comment Share on other sites More sharing options...
0 Elliot B. Posted December 9, 2015 Author Share Posted December 9, 2015 59 minutes ago, LimeMaster said: Try this, assuming I understood what you meant: Form2 frm2 = new Form2(); frm2.StartPosition = FormStartPosition.CenterParent; frm2.Show(); Where do I put that? If I double-click on the blue Change link, it goes to: Private Sub LinkLabel2_LinkClicked_2(sender As Object, e As LinkLabelLinkClickedEventArgs) Handles LinkLabel2.LinkClicked End Sub If I paste your code between there, it throws a lot of failures, so I guess I'm pasting it in the wrong location? Link to comment Share on other sites More sharing options...
0 BinaryData Posted December 9, 2015 Share Posted December 9, 2015 @Elliot B. - Think! Where should you put it? Part of learning how to code is figuring it out! Link to comment Share on other sites More sharing options...
0 Dick Montage Posted December 9, 2015 Share Posted December 9, 2015 Ignoring the above who seems to preach what he should have heeded less than 6 months back... I'm feeling that you may be missing some basic knowledge here. Care to paste either the errors or basic source? Link to comment Share on other sites More sharing options...
0 Elliot B. Posted December 9, 2015 Author Share Posted December 9, 2015 5 minutes ago, Nik L said: Ignoring the above who seems to preach what he should have heeded less than 6 months back... I'm feeling that you may be missing some basic knowledge here. Care to paste either the errors or basic source? Error BC32017 Comma, ')', or a valid expression continuation expected. WindowsApplication1 X:\LodarGUITest\WindowsApplication1\Form1.vb 159 Active Error BC30800 Method arguments must be enclosed in parentheses. WindowsApplication1 X:\LodarGUITest\WindowsApplication1\Form1.vb 159 Active Error BC30451 'frm2' is not declared. It may be inaccessible due to its protection level. WindowsApplication1 X:\LodarGUITest\WindowsApplication1\Form1.vb 159 Active Error BC30451 'frm2' is not declared. It may be inaccessible due to its protection level. WindowsApplication1 X:\LodarGUITest\WindowsApplication1\Form1.vb 160 Active Error BC30451 'frm2' is not declared. It may be inaccessible due to its protection level. WindowsApplication1 X:\LodarGUITest\WindowsApplication1\Form1.vb 161 Active Error BC30109 'Form2' is a class type and cannot be used as an expression. WindowsApplication1 X:\LodarGUITest\WindowsApplication1\Form1.vb 159 Active Error BC30037 Character is not valid. WindowsApplication1 X:\LodarGUITest\WindowsApplication1\Form1.vb 159 Active Error BC30037 Character is not valid. WindowsApplication1 X:\LodarGUITest\WindowsApplication1\Form1.vb 160 Active Error BC30037 Character is not valid. WindowsApplication1 X:\LodarGUITest\WindowsApplication1\Form1.vb 161 Active Link to comment Share on other sites More sharing options...
0 Andre S. Veteran Posted December 9, 2015 Veteran Share Posted December 9, 2015 Those are syntactic errors, not "throwing failures" ("throwing an error" or more precisely an "exception" is a run-time behavior, i.e. something that the code does when running - here the error happens at compile-time.) Visual Studio should underline these with red squigglies like in Word. If you double-click the error in the "Error List" window, it'll point you directly to it: it also gives you the line number where the error is. If you still can't figure it out, paste the offending code here. Note that you are using Visual Basic and that LimeMaster gave you C# code - you didn't specify which language you were using. You need to remove the semi-colons at the end of the lines and possibly there are other small discrepancies. Link to comment Share on other sites More sharing options...
0 LimeMaster Posted December 9, 2015 Share Posted December 9, 2015 9 minutes ago, Elliot B. said: Where do I put that? If I double-click on the blue Change link, it goes to: Private Sub LinkLabel2_LinkClicked_2(sender As Object, e As LinkLabelLinkClickedEventArgs) Handles LinkLabel2.LinkClicked End Sub If I paste your code between there, it throws a lot of failures, so I guess I'm pasting it in the wrong location? Oh, so you're using VB not C#. Oops, my mistake: Click the linkLabel and paste this: Form2.Show() Then double click Form2 and paste this: Me.StartPosition = FormStartPosition.CenterParent Link to comment Share on other sites More sharing options...
0 Elliot B. Posted December 9, 2015 Author Share Posted December 9, 2015 3 minutes ago, LimeMaster said: Oh, so you're using VB not C#. Oops, my mistake: Click the linkLabel and paste this: Form2.Show() Then double click Form2 and paste this: Me.StartPosition = FormStartPosition.CenterParent Much more like it - thank you a million! Link to comment Share on other sites More sharing options...
0 Dick Montage Posted December 9, 2015 Share Posted December 9, 2015 Damn, I take one phone call and miss all the fun. Link to comment Share on other sites More sharing options...
0 BinaryData Posted December 9, 2015 Share Posted December 9, 2015 8 minutes ago, Nik L said: Damn, I take one phone call and miss all the fun. Such is life... is it not? Link to comment Share on other sites More sharing options...
0 Elliot B. Posted December 9, 2015 Author Share Posted December 9, 2015 17 minutes ago, Nik L said: Damn, I take one phone call and miss all the fun. If it helps, the box isn't opening in the center of Form1 And for bonus stars, how do I "lock" Form1 until Form2 is closed? Link to comment Share on other sites More sharing options...
0 LimeMaster Posted December 9, 2015 Share Posted December 9, 2015 1 minute ago, Elliot B. said: If it helps, the box isn't opening in the center of Form1 And for bonus stars, how do I "lock" Form1 until Form2 is closed? Is Form1 at the center of the screen? Because if it is, then use the lazy CenterScreen method. Link to comment Share on other sites More sharing options...
0 Andre S. Veteran Posted December 9, 2015 Veteran Share Posted December 9, 2015 59 minutes ago, Elliot B. said: And for bonus stars, how do I "lock" Form1 until Form2 is closed? Use ShowDialog instead of Show. Link to comment Share on other sites More sharing options...
0 Elliot B. Posted December 10, 2015 Author Share Posted December 10, 2015 You guys are legends Link to comment Share on other sites More sharing options...
0 FloatingFatMan Posted December 14, 2015 Share Posted December 14, 2015 (edited) On 10/12/2015, 08:53:40, Elliot B. said: You guys are legends Seeing as you're just getting started, do you mind a suggestion? Drop VB.NET and learn C# instead. I know it might seem the easier option, and as far as .NET goes, just as capable as C#, but learning the syntax of C# will help you much more moving forward than VB will, due to its similarities with things such as Java, Javascript and C. You'll also find far more learning materials available in C# than you will in VB... Link to comment Share on other sites More sharing options...
0 Andre S. Veteran Posted December 14, 2015 Veteran Share Posted December 14, 2015 And you get paid more That said, if you know VB well it's very easy to switch to C#, almost all the features are equivalent with slightly different syntax. I actually started with VB too. Didn't last long, wanted to write XNA games and it only supported C#. Link to comment Share on other sites More sharing options...
Question
Elliot B.
I am using Microsoft Visual Studio Community 2015.
When I click on the blue Change link, I want it to open Form2 (below) in the center and on top of Form1 (above)
Any ideas?
Link to comment
Share on other sites
16 answers to this question
Recommended Posts