Home All Groups Group Topic Archive Search About

Need help re: vb.net windows forms

Author
23 Oct 2006 2:12 PM
jax1148
In my prject I have three forms:

frmMenu.vb
frmReherse.vb
frmWriteFile.vb

frmMenu.vb is my startup object. How do I call frmReherse.vb from
frmMenu.vb?

Thanks,
Howard

Author
23 Oct 2006 2:15 PM
iecs
Hello!

I think you should simply show the form.

Sub a()
frmReherse.Show()
End Sub

jax1***@yahoo.com wrote:
Show quoteHide quote
> In my prject I have three forms:
>
> frmMenu.vb
> frmReherse.vb
> frmWriteFile.vb
>
> frmMenu.vb is my startup object. How do I call frmReherse.vb from
> frmMenu.vb?
>
> Thanks,
> Howard
Author
23 Oct 2006 2:29 PM
Tim Patrick
There are a few different ways. First, we need to know the class names of
each file. I will assume that your classes are called FrmMenu, FrmReherse,
and so on.

The easiest way to display another form is to use its Show() or ShowDialog()
method from the My.Forms collection.

   My.Forms.FrmReherse.ShowDialog()

Or you can use the shortcut for this statement:

   FrmReherse.ShowDialog()

ShowDialog() opens the form "modally," which makes it the sole focus of your
application (in general). Using Show() instead opens the form, but allows
the user to switch to other open forms at any time.

A second method is to create a specific instance of the second form, and
open that.

Dim otherForm As FrmReherse
....
otherForm = New FrmReherse
otherForm.ShowDialog()

-----
Tim Patrick
Start-to-Finish Visual Basic 2005

Show quoteHide quote
> In my prject I have three forms:
>
> frmMenu.vb
> frmReherse.vb
> frmWriteFile.vb
> frmMenu.vb is my startup object. How do I call frmReherse.vb from
> frmMenu.vb?
>
> Thanks,
> Howard
Author
23 Oct 2006 4:04 PM
jax1148
On Mon, 23 Oct 2006 10:12:47 -0400, jax1***@yahoo.com wrote:

>In my prject I have three forms:
>
>frmMenu.vb
>frmReherse.vb
>frmWriteFile.vb
>
>frmMenu.vb is my startup object. How do I call frmReherse.vb from
>frmMenu.vb?
>
>Thanks,
>Howard


Dim otherForm As frmReherse
otherForm = New frmReherse
otherForm.ShowDialog()

worked !!!! thanks


FrmReherse.ShowDialog()

got and error message: reference to a non-shared member requires an
object reference
Author
23 Oct 2006 4:21 PM
Tim Patrick
If you are building a non-Windows-Forms application, the statement that failed
will certainly fail because My.Forms is not configured. My.Forms only appears
if you create a true Windows application. I assume that you are creating
a DLL or a User Control. In that case, just use the version that worked.

-----
Tim Patrick
Start-to-Finish Visual Basic 2005

Show quoteHide quote
> On Mon, 23 Oct 2006 10:12:47 -0400, jax1***@yahoo.com wrote:
>
>> In my prject I have three forms:
>>
>> frmMenu.vb
>> frmReherse.vb
>> frmWriteFile.vb
>> frmMenu.vb is my startup object. How do I call frmReherse.vb from
>> frmMenu.vb?
>>
>> Thanks,
>> Howard
> Dim otherForm As frmReherse
> otherForm = New frmReherse
> otherForm.ShowDialog()
> worked !!!! thanks
>
> FrmReherse.ShowDialog()
>
> got and error message: reference to a non-shared member requires an
> object reference
>
Author
23 Oct 2006 5:51 PM
rowe_newsgroups
> Dim otherForm As frmReherse
> otherForm = New frmReherse

You could also "one line it" and use

Dim otherForm as New frmReherse()

or even

Dim otherForm as frmReherse = New frmReherse()

It doesn't really matter which you use, it's mainly just personal
preference. I tend to believe it makes the code easier to read if you
just use one line to declare/instatiate a variable.

Thanks,

Seth Rowe


jax1***@yahoo.com wrote:
Show quoteHide quote
> On Mon, 23 Oct 2006 10:12:47 -0400, jax1***@yahoo.com wrote:
>
> >In my prject I have three forms:
> >
> >frmMenu.vb
> >frmReherse.vb
> >frmWriteFile.vb
> >
> >frmMenu.vb is my startup object. How do I call frmReherse.vb from
> >frmMenu.vb?
> >
> >Thanks,
> >Howard
>
>
> Dim otherForm As frmReherse
> otherForm = New frmReherse
> otherForm.ShowDialog()
>
> worked !!!! thanks
>
>
> FrmReherse.ShowDialog()
>
> got and error message: reference to a non-shared member requires an
> object reference