Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works
Photo

VISUAL BASIC


  • Please log in to reply

#1
MaverickSidewinder

MaverickSidewinder

    Member

  • Member
  • PipPipPip
  • 257 posts
Help!! :woot:

Its really urget, what is the code on VB6 to make a second form open (leaving the first open).
For example, i have Form1, on it i made a commandbutton...how do i have to configure form2 and the command button to open when i click on it?
(i would also like to put a button on form 2 to exit and leave form1 open)

Thanks! (i searched everywhere on the web!! all i found was stuff for .net :S)

Hope to get an answer!

:) ill check back tomorrow

p.s. please please do answer :tazz:
  • 0

Advertisements


#2
Simmy

Simmy

    Member

  • Member
  • PipPip
  • 27 posts
Hi MaverrickSideWinder,

It has been a while since I used VB and the version I used was VB5 but I think the code behind the cmd button would be:

Form2.Show
Form1.hide

or if you want to close the form:

Form2.open
Form1.close

Make sure you put the code behind the cmd button and not the form and make sure it is onclick i.e. when you are entering the code it is below cmdopenform2 onclick if you know what i mean.

I think that is right. Best bet if it doesnt work is to use the help system within vb. Go to help on the menu and type in "open form" If you are still struggling let me know and i will get you the right code.

Simmy.
  • 0

#3
Simmy

Simmy

    Member

  • Member
  • PipPip
  • 27 posts
Hi MaverrickSideWinder,

It has been a while since I used VB and the version I used was VB5 but I think the code behind the cmd button would be:

Form2.Show
Form1.hide

or if you want to close the form:

Form2.open
Form1.close

Make sure you put the code behind the cmd button and not the form and make sure it is onclick i.e. when you are entering the code it is below cmdopenform2 onclick if you know what i mean.

I think that is right. Best bet if it doesnt work is to use the help system within vb. Go to help on the menu and type in "open form" If you are still struggling let me know and i will get you the right code.

Simmy.
  • 0

#4
darth_ash

darth_ash

    Member 1K

  • Member
  • PipPipPipPip
  • 1,382 posts
Hi MaverickSidewinder,
When you make a form in VB6 or VB.NET a class is created for it. But in VB6 a global variable is also made with the same name as the form so that you can easily access it, this was removed from VB.NET to improve efficiency of the program, so multilpe form manipulation is a bit tougher in VB.NET for those people who never used the object-driven features in VB6.

Anyways back to your problem; In VB6 you can open form2 with a command-button in form1 by adding the following line of code in the click event for that command-button:
from2.Show
Show is method that all forms have by default.
The above code makes form2 a non-modal form.
Your form2 can also be a modal from, meaning you can't access form1 until form2 is closed or hidden, to make form2 modal, modify the code to:
from2.Show vbModal



For the 2nd problem, i.e. to exit from form2 using a button from form2 itself.
Type following line of code in the event for the exit button:
Me.Hide
Me is keyword in VB6, by which the current form can reference itself.
  • 0

#5
MaverickSidewinder

MaverickSidewinder

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 257 posts
Thank you very much guys!

Ill try everything you told me, if by any chance something doesn't work ill be sure to post the problem, the code and the error it displays :tazz:


Thanks again!
  • 0

#6
MaverickSidewinder

MaverickSidewinder

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 257 posts
Thank you very much guys!

GeeksToGo strikes again :tazz:


Thanks again!
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP