473,388 Members | 1,326 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

Reference a hidden form without using Me keyword

How can I reference a form (from withing a module for example) and make it
visible without using the keyword "Me" ?

I tried with the following code but nothing happened:

Public myform As Form1
myform = New Form1
myform.Show()

Of course my application defines a form called Form1.

Thanks in advance.

Nov 21 '05 #1
4 2008
The code snippet that you have posted will create a new instance of the Form1
and display it.

By what I understand from yur post is that, you already have an instance
created and you have hidden that instance and now you want to display this
hidden instance, right?

\\\

Public myform As Form1
myform = New Form1
'Hide the instance
myform.DefInstance.Hide()

'Show the hidden instance
myform.DefInstance.Show()
///

HTH
Nov 21 '05 #2
Sorry for the misunderstanding, it's my fault.

I do not want to create a new instance of the Form1. I just want to be able
to show and hide the "Main and Only form" that I use with code in a module
(or inside
the class Form1 but without using the "Me" keyword).

Also, what "DefInstance" is ? It is not an accepted keyword so what should I
put there ??

Thanks again.

"Sarika" <Sa****@discussions.microsoft.com> wrote in message
news:7A**********************************@microsof t.com...
The code snippet that you have posted will create a new instance of the Form1 and display it.

By what I understand from yur post is that, you already have an instance
created and you have hidden that instance and now you want to display this
hidden instance, right?

\\\

Public myform As Form1
myform = New Form1
'Hide the instance
myform.DefInstance.Hide()

'Show the hidden instance
myform.DefInstance.Show()
///

HTH


Nov 21 '05 #3
Apologies for my uncommented code. This is one way you could reference an
instance of your Form.

\\\
'Add this code to the Form1 class
Private Shared m_vb6FormDefInstance As Form1
Private Shared m_InitializingDefInstance As Boolean

'This property returns an instance of Form1
Public Shared Property DefInstance() As Form1
Get
If m_vb6FormDefInstance Is Nothing _
OrElse m_vb6FormDefInstance.IsDisposed Then
m_InitializingDefInstance = True
m_vb6FormDefInstance = New Form1()
m_InitializingDefInstance = False
End If
DefInstance = m_vb6FormDefInstance
End Get
Set(ByVal Value As Form1)
m_vb6FormDefInstance = Value
End Set
End Property
///

To show Form1 you need to add the statement
\\\
Form1.DefInstance.Show()
///

I am sure there could be simpler methods to achieving this.

Hopefully I answered your qn this time!
Nov 21 '05 #4
Complicated but it worked! Thanks

"Sarika" <Sa****@discussions.microsoft.com> wrote in message
news:AC**********************************@microsof t.com...
Apologies for my uncommented code. This is one way you could reference an
instance of your Form.

\\\
'Add this code to the Form1 class
Private Shared m_vb6FormDefInstance As Form1
Private Shared m_InitializingDefInstance As Boolean

'This property returns an instance of Form1
Public Shared Property DefInstance() As Form1
Get
If m_vb6FormDefInstance Is Nothing _
OrElse m_vb6FormDefInstance.IsDisposed Then
m_InitializingDefInstance = True
m_vb6FormDefInstance = New Form1()
m_InitializingDefInstance = False
End If
DefInstance = m_vb6FormDefInstance
End Get
Set(ByVal Value As Form1)
m_vb6FormDefInstance = Value
End Set
End Property
///

To show Form1 you need to add the statement
\\\
Form1.DefInstance.Show()
///

I am sure there could be simpler methods to achieving this.

Hopefully I answered your qn this time!

Nov 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: JKop | last post by:
Does that Standard explicitly forbid the initiation of a null reference? Is there anything wrong with the following code?: void Blah( std::string const &k ) { if ( !&k ) return; // work with...
2
by: Zippy | last post by:
Some months ago, we requested help from this newsgroup on how to replace the library reference of a database with another library reference, prior to creating an MDE. I got the following answer...
4
by: Cybertof | last post by:
Hello, What is the difference between : - adding a new reference to a namespace within the SolutionExplorer (right click, Add Reference...) - adding a new reference with the 'using' keyword in...
6
by: Lenn | last post by:
Hi, Could someone clarify my confusion regarding passing reference types to a method with ref keyword and explain when it's practical to use it. It's my understanding that in .NET reference...
2
by: Giovanni Bassi | last post by:
Hello All, I have encountered a problem. I am using visual inheritance and my base form adds an event handler on Form Load using the AddHandler Keyword. The problem is that if the Event...
3
by: Ann Huxtable | last post by:
I wrote a method that accepted a form. The signature was as ff: void foo(ref Form frm) ; I had to remove the ref keyword to get it to compile. Any idea why? I though forms would be passed by...
12
by: Andrew Bullock | last post by:
Hi, I have two classes, A and B, B takes an A as an argument in its constructor: A a1 = new A(); B b = new B(a1);
13
by: Francois Appert | last post by:
This post was originally in the C# Corner site, but their server is down. I'd like to see if this group can answer. I program in C++ and am learning C#. The issue is: why should anybody...
12
by: Bryan Parkoff | last post by:
I write my large project in C++ source code. My C++ source code contains approximate four thousand small functions. Most of them are inline. I define variables and functions in the global scope....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.