Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Mar 8th, 2007, 8:42 AM   #1
humpa
Newbie
 
Join Date: Mar 2007
Posts: 2
Rep Power: 0 humpa is on a distinguished road
Question How to link forms

Hi im relatively new to visual basic and i was wondering if anybody could help me. I'm trying to open a second form when i click a button on the first form, what is the code to do that. My programming teacher is to dumb and doesn't know how, so maybe you all could help. Thanks!
humpa is offline   Reply With Quote
Old Mar 8th, 2007, 9:02 AM   #2
Jimmy Bazooka
Newbie
 
Join Date: Mar 2007
Location: at this heap offset AF3A: 66C3
Posts: 10
Rep Power: 0 Jimmy Bazooka is an unknown quantity at this point
I'll help you! Just drop VB and turn to C++.
Jimmy Bazooka is offline   Reply With Quote
Old Mar 8th, 2007, 9:27 AM   #3
PhilBon
Hobbyist Programmer
 
PhilBon's Avatar
 
Join Date: Nov 2005
Posts: 172
Rep Power: 3 PhilBon is on a distinguished road
Send a message via AIM to PhilBon Send a message via MSN to PhilBon
Welcome to the Forums. Have you tried google-ing this? If not I suggest you do so. The next thing would be take up Jimmy's thought of learning C++. I will tell you this much. You create an object variable that references to the second form. So now you get to do some work and find out how to create a variable of an object of another form. It's quiet easy, I'll start it out for you: Dim mySecondForm as ___ _____ there you go, find out how to fill in those two blanks and you should be able to figure the rest out.
PhilBon is offline   Reply With Quote
Old Mar 8th, 2007, 11:36 AM   #4
milot
Programmer
 
milot's Avatar
 
Join Date: Nov 2006
Location: Kosovė/Prishtinė
Posts: 47
Rep Power: 0 milot is on a distinguished road
Hi,

I don't know Visual Basic but it's the same like in C#, so in C# I do something like shown below:

CSharp Syntax (Toggle Plain Text)
  1. private void button1_Click(object sender, EventArgs e)
  2. {
  3. Form2 form_var = new Form2();
  4. form_var.Show();
  5. //form_var.ShowDialog();
  6. }

and I converted the above code to VB.NET using developerfusion utility http://www.developerfusion.co.uk/uti...sharptovb.aspx to make the conversion and the VB code should look like below:

vbnet Syntax (Toggle Plain Text)
  1. Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs)
  2. Dim form_var As Form2 = New Form2
  3. form_var.Show
  4. 'form_var.ShowDialog
  5. End Sub

As you can see I have commented .ShowDialog() method. With the .Show() method we can manipulate with two opened forms we can minimize Form1 work with Form2 or opposite, but when we use .ShowDialog() method, we cannot work in Form1 while the Form2 is shown, it is like a MessageBox we should close Form2 and continue working with Form1. But keep in mind, in our case here Form2 is child form of the Form1, so if you are using .Show dialog and if you close Form1 the Form2 will close.

If you have further questions, or I didn't express so good, post a reply we hare here for this reason to help each other .
milot is offline   Reply With Quote
Old Mar 8th, 2007, 12:05 PM   #5
kruptof
Professional Programmer
 
kruptof's Avatar
 
Join Date: May 2006
Location: UK - London
Posts: 330
Rep Power: 3 kruptof is on a distinguished road
Quote:
Originally Posted by Jimmy Bazooka View Post
I'll help you! Just drop VB and turn to C++.
this was posted in the VB category, so obviously they are looking for an vb solution, and they did hint that they are studying this, i wonder what their lecturer would think if they handed in c++ code for an vb assignment

anyways...

i think you need to hide the current form and show the target form using the methods already provided by the forms:

currentform.hide
targetform.show
__________________
Quote:
When I was young it seemed that life was so wonderful,a miracle, oh it was beautiful, magical.
Now watch what you say or they'll be calling you a radical,a liberal, oh fanatical, criminal. Oh won't you sign up your name,we'd like to feel you're acceptable, respectable, oh presentable, a vegetable
kruptof is offline   Reply With Quote
Old Mar 8th, 2007, 4:11 PM   #6
zorin
Hobbyist Programmer
 
Join Date: Apr 2005
Posts: 218
Rep Power: 4 zorin is on a distinguished road
Stop telling him to learn a new language, it has nothing to do with his question and is not appriciated.
Quote:
Originally Posted by humpa View Post
Hi im relatively new to visual basic and i was wondering if anybody could help me. I'm trying to open a second form when i click a button on the first form, what is the code to do that. My programming teacher is to dumb and doesn't know how, so maybe you all could help. Thanks!
In visual basic create a button and go to the form code and add the following: "Form2.Show". Now your code should look like
Private Sub Command1_Click()
Form2.Show
End Sub
Obviously the Private Sub Command1_click() will be different if you have more than one button present on your form. Hope that helps a little.
zorin is offline   Reply With Quote
Old Mar 9th, 2007, 5:19 PM   #7
humpa
Newbie
 
Join Date: Mar 2007
Posts: 2
Rep Power: 0 humpa is on a distinguished road
Thanks alot everyone, well atleast everyone that helped me and didn't try to get me to learn C++. That's advanced programming in my school, and i'm not in that yet. Anyway thanks alot everyone you really helped!
humpa is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Form Link tayspen C# 1 Oct 26th, 2005 12:37 PM
Program compiling even without reference to required static link files c0ldshadow C++ 9 Sep 16th, 2005 5:11 PM
dynamically creating a link element glevine JavaScript and Client-Side Browser Scripting 5 Jul 14th, 2005 11:04 AM
Singly Linked List Help Firebar Java 3 May 22nd, 2005 10:56 AM
Getting parent forms object Mark67 Visual Basic 2 Jan 14th, 2005 10:38 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 3:32 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC