473,672 Members | 2,497 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.T ext = strMsg

MsgBox.ShowDial og()

MyMsgBox = MsgBox.Response

MsgBox.Close()

End If

End Function

Nov 21 '05 #1
7 1115
"anthony" <an*******@cont rolengineer.com > wrote in
news:uE******** *****@TK2MSFTNG P11.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********@rog ers.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*******@cont rolengineer.com > wrote in message
news:uE******** *****@TK2MSFTNG P11.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.T ext = strMsg

MsgBox.ShowDial og()

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******** ********@TK2MSF TNGP09.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*******@cont rolengineer.com > wrote in message
news:uE******** *****@TK2MSFTNG P11.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.T ext = strMsg

MsgBox.ShowDial og()

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 ShowMessageBoxF unction() 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*******@cont rolengineer.com > wrote in message
news:%2******** ********@TK2MSF TNGP11.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******** ********@TK2MSF TNGP09.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*******@cont rolengineer.com > wrote in message
news:uE******** *****@TK2MSFTNG P11.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.T ext = strMsg
>
> MsgBox.ShowDial og()
>
> 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 ShowMessageBoxF unction() 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******** ******@TK2MSFTN GP12.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 ShowMessageBoxF unction() 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*******@cont rolengineer.com > wrote in message
news:%2******** ********@TK2MSF TNGP11.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******** ********@TK2MSF TNGP09.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*******@cont rolengineer.com > wrote in message
news:uE******** *****@TK2MSFTNG P11.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.T ext = strMsg
>
> MsgBox.ShowDial og()
>
> 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******** ******@TK2MSFTN GP12.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 ShowMessageBoxF unction() 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*******@cont rolengineer.com > wrote in message
news:%2******** ********@TK2MSF TNGP11.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******** ********@TK2MSF TNGP09.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*******@cont rolengineer.com > wrote in message
news:uE******** *****@TK2MSFTNG P11.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.T ext = strMsg
>
> MsgBox.ShowDial og()
>
> 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*******@cont rolengineer.com > wrote in message
news:%2******** ********@TK2MSF TNGP12.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******** ******@TK2MSFTN GP12.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 ShowMessageBoxF unction() 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*******@cont rolengineer.com > wrote in message
news:%2******** ********@TK2MSF TNGP11.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******** ********@TK2MSF TNGP09.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*******@cont rolengineer.com > wrote in message
>> news:uE******** *****@TK2MSFTNG P11.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.T ext = strMsg
>> >
>> > MsgBox.ShowDial og()
>> >
>> > 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
5095
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 automate some information retrieval on a subscription web service I belong to, and have had much luck with similar sites using the XMLHTTP com to automatically POST the form data. However, in this case, I can't find the submission handler. The line in...
0
1007
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 structure and code. Judging by the forums I've researched, it's not an uncommon error. I'm happy to say I've found a simple solution. OVERVIEW: I have a main form (no record source) which contains two subforms. The subforms are not linked, but...
1
5755
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 reference.
2
5304
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 Handler code is there, when I create the inherited form I get the error "Object Reference not set to an instance of an object". If it is not I get no error. I have tried leaving this code in the forms Sub New, but it produces the
23
1280
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 Thanks
2
10703
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 module, it said cboxProcessRet is not declared (If cboxProcessRet.Checked = True ) ------------------------------------------------------------------------
4
1671
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 of PersonalInfo class, makes a call to the db and fills that class Here's the tricky part:
3
1400
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 like to dreive it from the reference to the form that I am already passing. Can this be done? TIA John
14
1984
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 on it. I have created these controls in the form design tool, and given them unique names. I would like to be able to put together a line of code that allows this:
2
4288
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: Me!subForm.Form!txtTextBox and for some reason, in certain contexts, we get the error: Error 2455: You entered an expression that has an invalid reference
0
8403
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8930
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8677
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7446
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6238
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5704
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4227
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4417
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2819
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.