473,396 Members | 1,734 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,396 software developers and data experts.

How to set module instance varaible to nothing for another Form?

I have a menu option that loads a form and displays infomation. if you go to
main form and try to load something else from that same menu, it does a
check to see if the form in exist and then reloads it has to or does
messagebox. the problem i have is that i want to set the module instance
varible to nothing when i exit the form that is being check.
The code i am use is

If frmWeatherMap Is Nothing Then
objWeatherMaps.WeatherMap = strMapLoc
frmWeatherMap = New frmWeatherMap()
frmWeatherMap.Show()
Else
MessageBox.Show("There is a Instance of Weather Maps already Runing" &
ControlChars.CrLf _
& "To see another map, Please use the Weather Map Menu in Weather Map
Window.", "Weather Map Instance Warning", MessageBoxButtons.OK,
MessageBoxIcon.Information)
End If
Nov 20 '05 #1
6 1419
Hi Shane,

Why do you want to set the form to nothing, that is normaly never done in
vb.net, it is hided, closed or with a dialogform disposed?

Cor

I have a menu option that loads a form and displays infomation. if you go to main form and try to load something else from that same menu, it does a
check to see if the form in exist and then reloads it has to or does
messagebox. the problem i have is that i want to set the module instance
varible to nothing when i exit the form that is being check.
The code i am use is

If frmWeatherMap Is Nothing Then
objWeatherMaps.WeatherMap = strMapLoc
frmWeatherMap = New frmWeatherMap()
frmWeatherMap.Show()
Else
MessageBox.Show("There is a Instance of Weather Maps already Runing" &
ControlChars.CrLf _
& "To see another map, Please use the Weather Map Menu in Weather Map
Window.", "Weather Map Instance Warning", MessageBoxButtons.OK,
MessageBoxIcon.Information)
End If

Nov 20 '05 #2
if i dont set it to nothing, when try to load the same form again, it tell
me that it already exist and it really does not. when the main form loads it
makes a form obj and does not release until the program closes. i wanted to
take the variable (dim frmMyform as frmMyForm) and set it nothing. the only
way i was think i could do that is to do showdialog, but i dont want to do
that. So wanted to set the frmMyForm to nothing, but i dont know how to do
that? i could do in the sub, then i should just not have the check there in
the first place.

Shane
"Cor Ligthert" <no**********@planet.nl> wrote in message
news:ua**************@TK2MSFTNGP10.phx.gbl...
Hi Shane,

Why do you want to set the form to nothing, that is normaly never done in
vb.net, it is hided, closed or with a dialogform disposed?

Cor

I have a menu option that loads a form and displays infomation. if you
go to
main form and try to load something else from that same menu, it does a
check to see if the form in exist and then reloads it has to or does
messagebox. the problem i have is that i want to set the module instance
varible to nothing when i exit the form that is being check.
The code i am use is

If frmWeatherMap Is Nothing Then
objWeatherMaps.WeatherMap = strMapLoc
frmWeatherMap = New frmWeatherMap()
frmWeatherMap.Show()
Else
MessageBox.Show("There is a Instance of Weather Maps already Runing" &
ControlChars.CrLf _
& "To see another map, Please use the Weather Map Menu in Weather Map
Window.", "Weather Map Instance Warning", MessageBoxButtons.OK,
MessageBoxIcon.Information)
End If


Nov 20 '05 #3
Hi Shane,

Did you close it, that is the normal way to archieve what you describe it in
my opinion.

And than you can create it new. However show what code, probably than it is
easier to help you.
Cor
if i dont set it to nothing, when try to load the same form again, it tell
me that it already exist and it really does not. when the main form loads it makes a form obj and does not release until the program closes. i wanted to take the variable (dim frmMyform as frmMyForm) and set it nothing. the only way i was think i could do that is to do showdialog, but i dont want to do
that. So wanted to set the frmMyForm to nothing, but i dont know how to do that? i could do in the sub, then i should just not have the check there in the first place.

Shane
"Cor Ligthert" <no**********@planet.nl> wrote in message
news:ua**************@TK2MSFTNGP10.phx.gbl...
Hi Shane,

Why do you want to set the form to nothing, that is normaly never done in vb.net, it is hided, closed or with a dialogform disposed?

Cor

I have a menu option that loads a form and displays infomation. if you

go
to
main form and try to load something else from that same menu, it does a check to see if the form in exist and then reloads it has to or does
messagebox. the problem i have is that i want to set the module instance varible to nothing when i exit the form that is being check.
The code i am use is

If frmWeatherMap Is Nothing Then
objWeatherMaps.WeatherMap = strMapLoc
frmWeatherMap = New frmWeatherMap()
frmWeatherMap.Show()
Else
MessageBox.Show("There is a Instance of Weather Maps already Runing" &
ControlChars.CrLf _
& "To see another map, Please use the Weather Map Menu in Weather Map
Window.", "Weather Map Instance Warning", MessageBoxButtons.OK,
MessageBoxIcon.Information)
End If



Nov 20 '05 #4
Cor,

Here is the code i am using.. this to check for the form

Dim strMapLoc As String
Private frmWeatherMap As frmWeatherMap < ------this what i want to set to
nothing on exit of the form

Private Sub MapCheck()
Dim objWeatherMaps As CWeatherMaps
objWeatherMaps = New CWeatherMaps()

Try

' Check to see if there is version already in memory, if not loads new one
or prompts the user that one exist already
If frmWeatherMap Is Nothing Then
objWeatherMaps.WeatherMap = strMapLoc
frmWeatherMap = New frmWeatherMap()
frmWeatherMap.Show()
Else
MessageBox.Show("There is a Instance of Weather Maps already Runing"
& ControlChars.CrLf _
& "To see another map, Please use the Weather Map Menu in Weather
Map Window.", "Weather Map Instance Warning", MessageBoxButtons.OK,
MessageBoxIcon.Information)
End If
Catch exc As Exception
MessageBox.Show(exc.Message, "Error Message", MessageBoxButtons.OK,
MessageBoxIcon.Error)
Exit Sub
End Try
End Sub

i want know how to do this.

Private Sub frmWeatherMap_Closed(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Closed
frmweathermap = nothing

End Sub
But this has to be the one on main form that i am setting to nothing

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:eA**************@TK2MSFTNGP10.phx.gbl...
Hi Shane,

Did you close it, that is the normal way to archieve what you describe it in my opinion.

And than you can create it new. However show what code, probably than it is easier to help you.
Cor
if i dont set it to nothing, when try to load the same form again, it tell
me that it already exist and it really does not. when the main form loads
it
makes a form obj and does not release until the program closes. i wanted to
take the variable (dim frmMyform as frmMyForm) and set it nothing. the

only
way i was think i could do that is to do showdialog, but i dont want to

do that. So wanted to set the frmMyForm to nothing, but i dont know how to

do
that? i could do in the sub, then i should just not have the check there

in
the first place.

Shane
"Cor Ligthert" <no**********@planet.nl> wrote in message
news:ua**************@TK2MSFTNGP10.phx.gbl...
Hi Shane,

Why do you want to set the form to nothing, that is normaly never done in vb.net, it is hided, closed or with a dialogform disposed?

Cor
> I have a menu option that loads a form and displays infomation. if you go
to
> main form and try to load something else from that same menu, it
does a > check to see if the form in exist and then reloads it has to or does
> messagebox. the problem i have is that i want to set the module instance > varible to nothing when i exit the form that is being check.
>
>
> The code i am use is
>
> If frmWeatherMap Is Nothing Then
> objWeatherMaps.WeatherMap = strMapLoc
> frmWeatherMap = New frmWeatherMap()
> frmWeatherMap.Show()
> Else
> MessageBox.Show("There is a Instance of Weather Maps already Runing"

& > ControlChars.CrLf _
> & "To see another map, Please use the Weather Map Menu in Weather Map > Window.", "Weather Map Instance Warning", MessageBoxButtons.OK,
> MessageBoxIcon.Information)
> End If
>
>



Nov 20 '05 #5
Hi Shane,

I never did it this way, however I think that this needs much your needs

You can try it,

I hope this helps?

Cor
\\\
Private frm As Form2
Private Sub Button1_Click(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles Button1.Click
If frm Is Nothing Then
frm = New Form2
frm.Show()
Else
If Not frm.Visible Then
frm.Show()
End If
End If
End Sub
///
\\\
Private Sub Form2_Closing(ByVal sender As Object, _
ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
e.Cancel = True
Me.Hide()
End Sub
///
Nov 20 '05 #6
Cor,
I Thank you for you help. I though of a better way to do it. I ended up
using boolean logic to to show if the form existed or not, and it works
just like i wanted it to.

Shane
"Cor Ligthert" <no**********@planet.nl> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Hi Shane,

I never did it this way, however I think that this needs much your needs

You can try it,

I hope this helps?

Cor
\\\
Private frm As Form2
Private Sub Button1_Click(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles Button1.Click
If frm Is Nothing Then
frm = New Form2
frm.Show()
Else
If Not frm.Visible Then
frm.Show()
End If
End If
End Sub
///
\\\
Private Sub Form2_Closing(ByVal sender As Object, _
ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing e.Cancel = True
Me.Hide()
End Sub
///

Nov 20 '05 #7

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

Similar topics

6
by: Bob | last post by:
Declaring a module level form object in multiple froms within a project to show another project form causes a stack overflow and other assorted errors. Can anyone help?
6
by: Dmitry Karneyev | last post by:
Hi! I guess this question have been asked a lot of times, but please be tolerant and if you have any ideas share it. The question is: how to make availibale only one instance of application and...
8
by: kyle | last post by:
Hi ther I have a small vb.net 2003 program with 5 forms: form1, form2, et I have a module in the program from where I want to launch form1 - the main for In the module I have a bunch of public...
4
by: http://www.visual-basic-data-mining.net/forum | last post by:
Hi Does anyone know how to stay connected to the server and at the same time i can pass the string to and from the module to the form..... What I want: I put the connection at the...
2
by: Bert Szoghy | last post by:
Hello, I am missing something about Visual Basic .NET module variables and window close events. In the following code, after opening Form2 by clicking a button on Form1 and then closing...
6
by: Bob Alston | last post by:
I am looking for Access reporting add-in that would be easy to use by end users. My key focus is on selection criteria. I am very happy with the Access report writer capabilities. As far as...
3
by: JoelH | last post by:
This is really weird... I'm using Visual Basic 2005 Express I have a form - Form1 - with a control called txtStatusBox I have a module attached to the solution for storing some other code. This...
9
by: Rudy | last post by:
Hello All! I'm a little confused on Public Class or Modules. Say I have a this on form "A" Public Sub Subtract() Dim Invoice As Decimal Dim Wage As Decimal Static PO As Decimal Invoice =...
3
by: Andy.I | last post by:
Hi I have a module where I put all my functions and sub procedures. How do I from the module best reference objects in other forms? I have a form with a datagrid, and in the module I have a...
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:
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.