Click to See Complete Forum and Search --> : About Forms Show


ISMSH
March 28th, 2004, 12:24 PM
Hello Friends ...

well i made two forms in VB.NET

well i put a boutton on it
and i need to know how to show the other form and hide !!

in vb 6 i was using this code :

Unload Form1
Load Form2
Form2.Show


please help friends :mad:
thanks

gasperCasper
March 28th, 2004, 12:30 PM
there are very similar methods in vb.net.
try

1) form.show OR
form.showdialog to display a form
2) form.hide OR
form.dispose or
form.close to hide/close the form.

HTH

ISMSH
March 28th, 2004, 12:38 PM
Thanks

but am sorry its not working !!!

my form name Is Webs

and when i write :

Webs.Show

Or

Webs.Hide

it gives me erorrs

it says :
Expression does not produce a value

why ???

gasperCasper
March 28th, 2004, 12:56 PM
can you post the code for the declaration + definition for your Webs form? (BTW, is it a windows app/form? The reason I am asking is that your form name is "Webs" - which relates to a web form)

Craig Gemmill
March 28th, 2004, 12:58 PM
This is one of the biggest changes that you will notice about forms in OOP VB.NET, compared to VB6. The form is no longer automatically constructed (shared) anymore. This means that you must create a new instance of the form in order to use it:



'
'Create an instance of the webs form
'
Dim fTemp as New Webs

'
'Display it
'
fTemp.Show
'fTemp.ShowDialog

ISMSH
March 28th, 2004, 04:28 PM
thanks guys

well mr. gasperCasper yes its windows app/form

and the form name ( Webs ) is realted to web pages i want to make it on it ... and to tell u the truth i finsh like this programs in VB6 in hours only !!!!

now am on it for about a week !!! and nothing DONE !!!!

welll what can i do
i started to get bored of it !!!

thanks guys for ur help i hope u don't get bored of me coz i know NOTHING IN IT !!!

:)

ISMSH
March 28th, 2004, 04:32 PM
Mr. Craig Gemmill

thanksssssssssss for help

i will try it and i hope it will work

and i will tell u if it worked or not

thanks :)

ISMSH
March 28th, 2004, 04:53 PM
IIT WORKED !!!

thanks Mr.Craig Gemmill


but still something ... lol

well now i can start my ( Webs ) from and from it i can start the other forms ... but the problim here is :

how can i close this form when others are working i mean afte i start the other form i want to close this ( Webs ) form so it won't sty on the screen ???
and the other will work .

lol i know i am asking tooooooooooooo much ... lol

but don't leave me now guys ... lol

swamivishal1
March 30th, 2004, 08:09 AM
dear friend u can use

form.close
or
form.dispose

if u wants to close the form from any other form then when u open it u have to declare it as public and then u can simply write form.close

like in your case

Public Dim fTemp as New Webs

fTemp.Show

now in other form
ftemp.close

hope ur problem will be solved.

good luck

ISMSH
March 30th, 2004, 12:26 PM
Thanks Mr.swamivishal1 i will try this :)

ISMSH
March 31st, 2004, 01:13 PM
Well MR.swamivishal1
MR.Craig Gemmill
MR.gasperCasper

I am geeting bored of this !!!

the form won't close !!!!!!!!!!!!!!!!!!!!!!! WHY

i made this :

Module Module1
Public f1 As New Form1()
Public f2 As New Form2()
End Module

In button in Form1 i put this :
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

f2.Show()

End Sub

- - - - - - - - - - - -

In Form Load in Form2 i put this :
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

f1.Close()

End Sub

- - - - - - - - - - - -

Now what !!! the form1 still not closed and form2 is working so i have both forms 1&2 showing in my screen and i don't want this i want :

when ithe program start it will start form1 for Example .... then with a button i want to start another form and close this one i am using utill i come back to it .

Well any help guys !!!

Mr.Orange
March 31st, 2004, 02:18 PM
Try this:

1) Change the Startup Object setting in the Property Page of your application to: Sub Main

2) Change your code as follows:

Module Module1

Public f1 As New Form1
Public f2 As New Form2

Sub Main()
f1.ShowDialog()
f2.ShowDialog()
End Sub

End Module

In button in Form1:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Me.Close()

End Sub

Hope this helps.

gasperCasper
March 31st, 2004, 02:37 PM
you may also try this:


In button in Form1 :
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

f2.Show()

me.close() 'Close f1 right then!

End Sub


U shud get it!

ISMSH
March 31st, 2004, 02:48 PM
Mr.Orange thanks for ur help its worked very good it closed the form but the problim is its closed the all program !!!

i made this in the button after i made what u said in modul1 :

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

f2.Show()
Me.Close()

End Sub

its closed the alllllllllll program and end it with showing me the other form ( F2.Show ) !!!

is there any adiea about this ?

Mr.Orange
March 31st, 2004, 03:17 PM
My guess is that you didn't do the first step I mentioned:

1) Change the Startup Object setting in the Property Page of your application to: Sub Main

The Property Page can be accessed from the Project menu (Properties...).

You may also have to make sure that the visible property of each form is set to False before you call ShowDialog.

You will probably need some sort of loop to get your application working as you want it to.

Here's a simple example:

Module GLOBALS
Public RUN_APP As Boolean
End Module

Module Module1
Private f1 As New Form1
Private f2 As New Form2

Sub Main()
RUN_APP = True
Do While RUN_APP = True
Show_f1()
Show_f2()
Loop
End Sub

Sub Show_f1()
If RUN_APP = True Then
f1.Visible = False
f1.ShowDialog()
End If
End Sub

Sub Show_f2()
If RUN_APP = True Then
f2.Visible = False
f2.ShowDialog()
End If
End Sub
End Module

Public Class Form1
Inherits System.Windows.Forms.Form

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.Close()
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
RUN_APP = False
Me.Close()
End Sub
End Class

Public Class Form2
Inherits System.Windows.Forms.Form

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.Close()
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
RUN_APP = False
Me.Close()
End Sub
End Class

ISMSH
March 31st, 2004, 03:55 PM
Thankssssssssssssss Mr.Orange

i really didn't do ur first Step ... and nowi did this step and its worked GREATTTTTTTTT !!!

but i had to put this code in module :

Module Module1
Public f1 As New Form1()
Public f2 As New Form2()

Sub Main()
f1.Visible = False ' This One
f1.ShowDialog()
f2.Visible = False ' This One
f2.ShowDialog()

End Sub

End Module

am really thankful Mr.Orange i will be in touch if i have any problim ... lol

And thanks to all ppl who try to help me :)


:) :) :)

ISMSH
April 1st, 2004, 01:58 PM
Hello Again Guys :)

well about picture box !!!

when i put it Streach Image it won't work !!!

in vb.6 there was something called ( Image ) it work with pictures very good with Streach ..

Is there any aidea about this ?
----------------------------------------
Also about MsgBox !!!

Can i change the font inside the MsgBox and the color of fonts ?
----------------------------------------
About Screen Width !!!

can i make a small program that change the Screen width to run good with my program ?

like if the Screen Width is : 800 × 600

I want it to give the User Massage to till him that u have to change to : 1024 × 768 and change it if he click yes ?

lol i think i am asking too much but please i need help if u knew anythings of this plaese help me !!!


Thankssssssssssssssssss :) :) :)

Craig Gemmill
April 1st, 2004, 02:56 PM
Picturebox: PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage

Msgbox: Yes, but not easily. You are better off creating a new form that you use as a custom msgbox.

Resolution: Here's an example from MSDN...

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnGetScreenInfo.Click

Dim Index As Integer
Dim UpperBound As Integer

' Gets an array of all the screens connected to the system.

Dim Screens() As System.Windows.Forms.Screen = _
System.Windows.Forms.Screen.AllScreens
UpperBound = Screens.GetUpperBound(0)

For Index = 0 To UpperBound

' For each screen, add the screen properties to a list box.

ListBox1.Items.Add("Device Name: " + Screens(Index).DeviceName)
ListBox1.Items.Add("Bounds: " + Screens(Index).Bounds.ToString())
ListBox1.Items.Add("Type: " + Screens(Index).GetType().ToString())
ListBox1.Items.Add("Working Area: " + Screens(Index).WorkingArea.ToString())
ListBox1.Items.Add("Primary Screen: " + Screens(Index).Primary.ToString())

Next



End Sub


And here's an example of how to change the resolution (http://www.devcity.net/forums/attachment.asp?id=6510) , found here. (http://www.devcity.net/forums/topic.asp?tid=61985)

ISMSH
April 1st, 2004, 03:02 PM
I am reall Tahnksfull Mr.Craig Gemmill

i will try them all .

i think i have much work now ... lol

:)

I will be in touch with you if there is something new :)

ISMSH
April 2nd, 2004, 01:27 PM
Well guys i really need help this time ... lol

well i finshed the project and its workinggggggggg GREAT !!!
and thanks to you all coz u helped me on it ...

well i was happy i put it in CD and i move to work ... but then :(
IT WON'T WORK !!!

it says Application Error !!! :(

but i put all the folder i made the project on it in the CD !!!

all forms and things and every every every THINGS !!

So what ???

someone told me and i don't know if he is right or not that i have to make setup coz u r moving to another PC but i told him in VB.6 i wasent make setup and it was working Great !!!

so what now Guys .... i don't know how to make Setup and its only 24 hours to give the progect to my BOSS !!

is there is any help ... or i better leave it .

thanks guys for helping me before coz the program was working great in my pc .


Thenksssssssssss

DeepButi
April 2nd, 2004, 03:32 PM
I'm not an expert ... but you're running out of time ... so

In .NET you need to have the .NET frame deployed, so try making a development project. In the same solution, add a development project ... choose wizard and follow its instruccions ... I'm not sure if this will be enough.

If it does not, then follow Mr.Orange advise:

http://www.codeguru.com/forum/showthread.php?s=&threadid=289247 :

2) Distributing the .Net framework (dotnetfx.exe) with your application.

Hope it helps

TheCPUWizard
April 2nd, 2004, 08:46 PM
Just following this thread makes my head hurt!

It seems like the application REALLY only wants a SINGLE form [I could not find any point in the discussion where there is more thn one form active....]

If this is the case, why is the application noit being designed as a single form????????

Multiple forms apply to a number of solutions, but not to all of them.

If you could please provide a reason for needing more than one form object, I will be glad to give any pointers I can. Otherwise JUST use a single form [Dynamic user control instanciation, plugin display panels etc].

ISMSH
April 2nd, 2004, 10:17 PM
Thanks Mr.DeepButi

Thanks Mr.TheCPUWizard


well where i found .Net framework (dotnetfx.exe) Distributing it with my application.

the program ask for this also .


thanks for help guys ... :)

swamivishal1
April 3rd, 2004, 06:25 AM
dear friend

u will find .Net framework at the update cd of your .net setup cds.

it (as i remember cd no. 5) of your .net distribution pack.

also it is freely available with many magzine cd.
also u can download it from microsoft's website.

hope u find it

good luck
vishal

ISMSH
April 3rd, 2004, 12:13 PM
Thanks Mr.swamivishal1

i really found it in CD No. 5

:) :) :)

ISMSH
April 3rd, 2004, 12:22 PM
Well guys i made my BOSS cry ... LOL

i finshed the program at the time and he didn't believe it ... lol

i made th Setup also and its working in any PC now :)

i am at work now and when i come back home in about 4 hours i will post how i made the setup if someone intrested or needed it

LOVE YOU FRIENDS :) u helped me in this program i am very Thanksful

see you latter :)

Craig Gemmill
April 3rd, 2004, 02:11 PM
So... when do we get paid? ;)

ISMSH
April 3rd, 2004, 03:39 PM
Thanks Mr.Craig Gemmill for your posts :)
well thanks everybody

i have small qouestion only guys ... lol
and this qouestion is needed for my not for my work so i can be better in VB.Net coz i am learning it ...


well the program is working Perfect , and i made a setup program for it and its also working perfcet ... but i had to put all files in the setup and it was about ( 300 MG ) so it download it from the CD to the Computer that it wanted to work on it ....

anyway is there is a way to let the program read files form the CD .... ??? please help if there is a way coz i really like to know it

thanks u again guys :)