473,406 Members | 2,336 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,406 software developers and data experts.

how to reference form property?

I tried sth i did b4 in VB, now in VB.NET, but since the form is created
every time, the following code would not work because MsgBox.Visible is
always false, any idea? Thanks!

Public Function MyMsgBox(ByVal strMsg As String, ByVal MsgType As Integer,
ByVal strTitle As String) As Integer

Dim MsgBox As New frmMsgBox

If MsgBox.Visible = False Then

MsgBox.Text = strTitle

MsgBox.MsgType = MsgType

MsgBox.lblMsg.Text = strMsg

MsgBox.ShowDialog()

MyMsgBox = MsgBox.Response

MsgBox.Close()

End If

End Function

Nov 21 '05 #1
7 1100
"anthony" <an*******@controlengineer.com> wrote in
news:uE*************@TK2MSFTNGP11.phx.gbl:
I tried sth i did b4 in VB, now in VB.NET, but since the form is
created every time, the following code would not work because
MsgBox.Visible is always false, any idea? Thanks!

Public Function MyMsgBox(ByVal strMsg As String, ByVal MsgType As
Integer, ByVal strTitle As String) As Integer

Dim MsgBox As New frmMsgBox


Set Msgbox as a class variable.
--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
Nov 21 '05 #2
MsgBox.visble will be false until .showdialog or .show is called.

On top of that the .showdialog is a blocking call, so nothing else can
happen in this function until it returns from .showdialog.
You don't need to do the .Close either since .ShowDialog won't return until
the box is closed. Also instead of doing MyMsgBox = MsgBox.Response, you
can now use the "Return MsgBox.Response" Which is the newer way of doing
it, and I, personally think the correct way <grin>

What are you trying to accomplish here? Since you just created the MsgBox
object, there is reason to check MsgBox.Visible, you know for sure that it
isn't showing because you just created it. It looks like you are just
trying to replace the messagebox class. If that is the case then just take
out the Msgbox.Visible = False and then .Close and you will be good.

Chris
"anthony" <an*******@controlengineer.com> wrote in message
news:uE*************@TK2MSFTNGP11.phx.gbl...
I tried sth i did b4 in VB, now in VB.NET, but since the form is created
every time, the following code would not work because MsgBox.Visible is
always false, any idea? Thanks!

Public Function MyMsgBox(ByVal strMsg As String, ByVal MsgType As Integer,
ByVal strTitle As String) As Integer

Dim MsgBox As New frmMsgBox

If MsgBox.Visible = False Then

MsgBox.Text = strTitle

MsgBox.MsgType = MsgType

MsgBox.lblMsg.Text = strMsg

MsgBox.ShowDialog()

MyMsgBox = MsgBox.Response

MsgBox.Close()

End If

End Function

Nov 21 '05 #3
Thanks,

I am trying to have my custom error/warning message box, I used it in some
timer control, so I dont want to have too many message box opened if the
user hasnt acknowledged, in other words, just one message box on top, it
will not be replaced neither, new warning message only appears if the old
one is clicked OK.

But the NEW keyword creates a new form every time.
"Chris, Master of all Things Insignificant" <chris@No_Spam_Please.com> wrote
in message news:%2****************@TK2MSFTNGP09.phx.gbl...
MsgBox.visble will be false until .showdialog or .show is called.

On top of that the .showdialog is a blocking call, so nothing else can
happen in this function until it returns from .showdialog.
You don't need to do the .Close either since .ShowDialog won't return until the box is closed. Also instead of doing MyMsgBox = MsgBox.Response, you
can now use the "Return MsgBox.Response" Which is the newer way of doing
it, and I, personally think the correct way <grin>

What are you trying to accomplish here? Since you just created the MsgBox
object, there is reason to check MsgBox.Visible, you know for sure that it
isn't showing because you just created it. It looks like you are just
trying to replace the messagebox class. If that is the case then just take out the Msgbox.Visible = False and then .Close and you will be good.

Chris
"anthony" <an*******@controlengineer.com> wrote in message
news:uE*************@TK2MSFTNGP11.phx.gbl...
I tried sth i did b4 in VB, now in VB.NET, but since the form is created
every time, the following code would not work because MsgBox.Visible is
always false, any idea? Thanks!

Public Function MyMsgBox(ByVal strMsg As String, ByVal MsgType As Integer, ByVal strTitle As String) As Integer

Dim MsgBox As New frmMsgBox

If MsgBox.Visible = False Then

MsgBox.Text = strTitle

MsgBox.MsgType = MsgType

MsgBox.lblMsg.Text = strMsg

MsgBox.ShowDialog()

MyMsgBox = MsgBox.Response

MsgBox.Close()

End If

End Function


Nov 21 '05 #4
I don't clam to understand your setup completely, but why have a timer fire
off warning messages? By using that showdialog the whole system will stop
until the user acknowledges the messagebox. If I was going to do what you
are talking about do something like this.

Public Class Foo

Dim MyMsgBox as frmMsgBox

Function ShowMessageBoxFunction() as Integer
If MyMsgBox is nothing then
'Hey there already is a live messagebox, leave
return -1
else
MyMsgbox = new frmMsgBox
'Do bunch of stuff
end if

End Function

End Class

This way you have a variable to check all the time if there is a messagebox
showing or not. But llike I said, you have other logic problems going on as
to when the user will see the box. Do you need processing to be done while
the error message is on the screen?

Chris


"anthony" <an*******@controlengineer.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Thanks,

I am trying to have my custom error/warning message box, I used it in some
timer control, so I dont want to have too many message box opened if the
user hasnt acknowledged, in other words, just one message box on top, it
will not be replaced neither, new warning message only appears if the old
one is clicked OK.

But the NEW keyword creates a new form every time.
"Chris, Master of all Things Insignificant" <chris@No_Spam_Please.com>
wrote
in message news:%2****************@TK2MSFTNGP09.phx.gbl...
MsgBox.visble will be false until .showdialog or .show is called.

On top of that the .showdialog is a blocking call, so nothing else can
happen in this function until it returns from .showdialog.
You don't need to do the .Close either since .ShowDialog won't return

until
the box is closed. Also instead of doing MyMsgBox = MsgBox.Response, you
can now use the "Return MsgBox.Response" Which is the newer way of doing
it, and I, personally think the correct way <grin>

What are you trying to accomplish here? Since you just created the
MsgBox
object, there is reason to check MsgBox.Visible, you know for sure that
it
isn't showing because you just created it. It looks like you are just
trying to replace the messagebox class. If that is the case then just

take
out the Msgbox.Visible = False and then .Close and you will be good.

Chris
"anthony" <an*******@controlengineer.com> wrote in message
news:uE*************@TK2MSFTNGP11.phx.gbl...
>I tried sth i did b4 in VB, now in VB.NET, but since the form is created
> every time, the following code would not work because MsgBox.Visible is
> always false, any idea? Thanks!
>
>
>
> Public Function MyMsgBox(ByVal strMsg As String, ByVal MsgType As Integer, > ByVal strTitle As String) As Integer
>
> Dim MsgBox As New frmMsgBox
>
> If MsgBox.Visible = False Then
>
> MsgBox.Text = strTitle
>
> MsgBox.MsgType = MsgType
>
> MsgBox.lblMsg.Text = strMsg
>
> MsgBox.ShowDialog()
>
> MyMsgBox = MsgBox.Response
>
> MsgBox.Close()
>
> End If
>
> End Function
>
>
>



Nov 21 '05 #5
Sorry, slight correction. I had my if statement backward, throw in a not it
works like it says it does.
Chris
Public Class Foo

Dim MyMsgBox as frmMsgBox

Function ShowMessageBoxFunction() as Integer
If Not MyMsgBox is nothing then
'Hey there already is a live messagebox, leave
return -1
else
MyMsgbox = new frmMsgBox
'Do bunch of stuff
end if

End Function

End Class

"Chris, Master of all Things Insignificant" <chris@No_Spam_Please.com> wrote
in message news:uD**************@TK2MSFTNGP12.phx.gbl...I don't clam to understand your setup completely, but why have a timer fire
off warning messages? By using that showdialog the whole system will stop
until the user acknowledges the messagebox. If I was going to do what you
are talking about do something like this.

Public Class Foo

Dim MyMsgBox as frmMsgBox

Function ShowMessageBoxFunction() as Integer
If MyMsgBox is nothing then
'Hey there already is a live messagebox, leave
return -1
else
MyMsgbox = new frmMsgBox
'Do bunch of stuff
end if

End Function

End Class

This way you have a variable to check all the time if there is a
messagebox showing or not. But llike I said, you have other logic
problems going on as to when the user will see the box. Do you need
processing to be done while the error message is on the screen?

Chris


"anthony" <an*******@controlengineer.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Thanks,

I am trying to have my custom error/warning message box, I used it in
some
timer control, so I dont want to have too many message box opened if the
user hasnt acknowledged, in other words, just one message box on top, it
will not be replaced neither, new warning message only appears if the old
one is clicked OK.

But the NEW keyword creates a new form every time.
"Chris, Master of all Things Insignificant" <chris@No_Spam_Please.com>
wrote
in message news:%2****************@TK2MSFTNGP09.phx.gbl...
MsgBox.visble will be false until .showdialog or .show is called.

On top of that the .showdialog is a blocking call, so nothing else can
happen in this function until it returns from .showdialog.
You don't need to do the .Close either since .ShowDialog won't return

until
the box is closed. Also instead of doing MyMsgBox = MsgBox.Response,
you
can now use the "Return MsgBox.Response" Which is the newer way of
doing
it, and I, personally think the correct way <grin>

What are you trying to accomplish here? Since you just created the
MsgBox
object, there is reason to check MsgBox.Visible, you know for sure that
it
isn't showing because you just created it. It looks like you are just
trying to replace the messagebox class. If that is the case then just

take
out the Msgbox.Visible = False and then .Close and you will be good.

Chris
"anthony" <an*******@controlengineer.com> wrote in message
news:uE*************@TK2MSFTNGP11.phx.gbl...
>I tried sth i did b4 in VB, now in VB.NET, but since the form is
>created
> every time, the following code would not work because MsgBox.Visible
> is
> always false, any idea? Thanks!
>
>
>
> Public Function MyMsgBox(ByVal strMsg As String, ByVal MsgType As

Integer,
> ByVal strTitle As String) As Integer
>
> Dim MsgBox As New frmMsgBox
>
> If MsgBox.Visible = False Then
>
> MsgBox.Text = strTitle
>
> MsgBox.MsgType = MsgType
>
> MsgBox.lblMsg.Text = strMsg
>
> MsgBox.ShowDialog()
>
> MyMsgBox = MsgBox.Response
>
> MsgBox.Close()
>
> End If
>
> End Function
>
>
>



Nov 21 '05 #6
thx, ur method works, just need to set MyMsgbox = Nothing at the end of the
else statement.

the warning message only fired if there is a run time error, like a file not
found error, i just dont want to have the same message box opened multiple
times.
"Chris, Master of all Things Insignificant" <chris@No_Spam_Please.com> wrote
in message news:uD**************@TK2MSFTNGP12.phx.gbl...
I don't clam to understand your setup completely, but why have a timer fire off warning messages? By using that showdialog the whole system will stop
until the user acknowledges the messagebox. If I was going to do what you
are talking about do something like this.

Public Class Foo

Dim MyMsgBox as frmMsgBox

Function ShowMessageBoxFunction() as Integer
If MyMsgBox is nothing then
'Hey there already is a live messagebox, leave
return -1
else
MyMsgbox = new frmMsgBox
'Do bunch of stuff
end if

End Function

End Class

This way you have a variable to check all the time if there is a messagebox showing or not. But llike I said, you have other logic problems going on as to when the user will see the box. Do you need processing to be done while the error message is on the screen?

Chris


"anthony" <an*******@controlengineer.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Thanks,

I am trying to have my custom error/warning message box, I used it in some timer control, so I dont want to have too many message box opened if the
user hasnt acknowledged, in other words, just one message box on top, it
will not be replaced neither, new warning message only appears if the old one is clicked OK.

But the NEW keyword creates a new form every time.
"Chris, Master of all Things Insignificant" <chris@No_Spam_Please.com>
wrote
in message news:%2****************@TK2MSFTNGP09.phx.gbl...
MsgBox.visble will be false until .showdialog or .show is called.

On top of that the .showdialog is a blocking call, so nothing else can
happen in this function until it returns from .showdialog.
You don't need to do the .Close either since .ShowDialog won't return

until
the box is closed. Also instead of doing MyMsgBox = MsgBox.Response, you can now use the "Return MsgBox.Response" Which is the newer way of doing it, and I, personally think the correct way <grin>

What are you trying to accomplish here? Since you just created the
MsgBox
object, there is reason to check MsgBox.Visible, you know for sure that
it
isn't showing because you just created it. It looks like you are just
trying to replace the messagebox class. If that is the case then just

take
out the Msgbox.Visible = False and then .Close and you will be good.

Chris
"anthony" <an*******@controlengineer.com> wrote in message
news:uE*************@TK2MSFTNGP11.phx.gbl...
>I tried sth i did b4 in VB, now in VB.NET, but since the form is created > every time, the following code would not work because MsgBox.Visible is > always false, any idea? Thanks!
>
>
>
> Public Function MyMsgBox(ByVal strMsg As String, ByVal MsgType As

Integer,
> ByVal strTitle As String) As Integer
>
> Dim MsgBox As New frmMsgBox
>
> If MsgBox.Visible = False Then
>
> MsgBox.Text = strTitle
>
> MsgBox.MsgType = MsgType
>
> MsgBox.lblMsg.Text = strMsg
>
> MsgBox.ShowDialog()
>
> MyMsgBox = MsgBox.Response
>
> MsgBox.Close()
>
> End If
>
> End Function
>
>
>



Nov 21 '05 #7
But I have to ask again. Why have a "timer" show the message? Isn't your
system suppose to stop everything if there is a runtime error?

Chris
"anthony" <an*******@controlengineer.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
thx, ur method works, just need to set MyMsgbox = Nothing at the end of
the
else statement.

the warning message only fired if there is a run time error, like a file
not
found error, i just dont want to have the same message box opened multiple
times.
"Chris, Master of all Things Insignificant" <chris@No_Spam_Please.com>
wrote
in message news:uD**************@TK2MSFTNGP12.phx.gbl...
I don't clam to understand your setup completely, but why have a timer

fire
off warning messages? By using that showdialog the whole system will
stop
until the user acknowledges the messagebox. If I was going to do what
you
are talking about do something like this.

Public Class Foo

Dim MyMsgBox as frmMsgBox

Function ShowMessageBoxFunction() as Integer
If MyMsgBox is nothing then
'Hey there already is a live messagebox, leave
return -1
else
MyMsgbox = new frmMsgBox
'Do bunch of stuff
end if

End Function

End Class

This way you have a variable to check all the time if there is a

messagebox
showing or not. But llike I said, you have other logic problems going on

as
to when the user will see the box. Do you need processing to be done

while
the error message is on the screen?

Chris


"anthony" <an*******@controlengineer.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
> Thanks,
>
> I am trying to have my custom error/warning message box, I used it in some > timer control, so I dont want to have too many message box opened if
> the
> user hasnt acknowledged, in other words, just one message box on top,
> it
> will not be replaced neither, new warning message only appears if the old > one is clicked OK.
>
> But the NEW keyword creates a new form every time.
>
>
> "Chris, Master of all Things Insignificant" <chris@No_Spam_Please.com>
> wrote
> in message news:%2****************@TK2MSFTNGP09.phx.gbl...
>> MsgBox.visble will be false until .showdialog or .show is called.
>>
>> On top of that the .showdialog is a blocking call, so nothing else can
>> happen in this function until it returns from .showdialog.
>> You don't need to do the .Close either since .ShowDialog won't return
> until
>> the box is closed. Also instead of doing MyMsgBox = MsgBox.Response, you >> can now use the "Return MsgBox.Response" Which is the newer way of doing >> it, and I, personally think the correct way <grin>
>>
>> What are you trying to accomplish here? Since you just created the
>> MsgBox
>> object, there is reason to check MsgBox.Visible, you know for sure
>> that
>> it
>> isn't showing because you just created it. It looks like you are just
>> trying to replace the messagebox class. If that is the case then just
> take
>> out the Msgbox.Visible = False and then .Close and you will be good.
>>
>> Chris
>>
>>
>> "anthony" <an*******@controlengineer.com> wrote in message
>> news:uE*************@TK2MSFTNGP11.phx.gbl...
>> >I tried sth i did b4 in VB, now in VB.NET, but since the form is created >> > every time, the following code would not work because MsgBox.Visible is >> > always false, any idea? Thanks!
>> >
>> >
>> >
>> > Public Function MyMsgBox(ByVal strMsg As String, ByVal MsgType As
> Integer,
>> > ByVal strTitle As String) As Integer
>> >
>> > Dim MsgBox As New frmMsgBox
>> >
>> > If MsgBox.Visible = False Then
>> >
>> > MsgBox.Text = strTitle
>> >
>> > MsgBox.MsgType = MsgType
>> >
>> > MsgBox.lblMsg.Text = strMsg
>> >
>> > MsgBox.ShowDialog()
>> >
>> > MyMsgBox = MsgBox.Response
>> >
>> > MsgBox.Close()
>> >
>> > End If
>> >
>> > End Function
>> >
>> >
>> >
>>
>>
>
>



Nov 21 '05 #8

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

Similar topics

1
by: Shannon | last post by:
Hi, all -- this is a weird question that does not really have to do with javascript, but I used to spend a lot of time here, and am hoping someone might be able to help... I am trying to...
0
by: John Hunter | last post by:
I've recently had a nasty problem with the "Invalid reference to the property Form" error in subforms - nasty because it doesn't seem to consistently happen to all forms which contain the same...
1
by: S. van Beek | last post by:
Dear reader, I can "able" and "unable" (disable) reference libraries in the reference form of VBA with Tools/References.. But is there code available in VBA to disable a missing...
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...
23
by: Carlos | last post by:
Before in VB 6 I used to reference for examplea progressbar1 doin the following Form1.ProgressBar1.val =1 Now how do I refrence a control for a module if the control is in a different form ...
2
by: JenHu | last post by:
Hi all, I have a checkbox cboxProcessRet in my VB.NET windows application's main.vb as following, so how can I use reference this checkbox in moduleA.vb? I want to use it in a function in the...
4
by: William Oliveri | last post by:
Is there a way to reference a calling form and pass an object to it? This is what I'm trying to do: Form A creates new instance of Form B and then calls it modal. Form B creates a new instance...
3
by: J L | last post by:
I have a from with an ErrorProvider on it. I pass a reference of the form to a subroutine where I want to reference the ErorrProvider. I could pass it in the call to the subroutine, but I would...
14
by: 97T | last post by:
Well this is still bugging me. I know there are other ways around this, but for a number of reasons I would like to be able to do this one simple thing. I have a form with a number of controls...
2
by: David W. Fenton | last post by:
I think at various times we've all encountered this problem: A subform is on a main form. From the code of the main form we refer to some property of/control on the child form thus: ...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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:
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...
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.