[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Opening a form and running a sub - can it also be dialog?

Posted on 2006-11-16
8
Medium Priority
?
180 Views
Last Modified: 2010-04-23
hi there

I would like to open a form as a dialog form.  However I also need to call a sub on the opened form (I call the same form in a lot of places so the sub I am running is important, and I load child forms onto the loaded form) i.e.

dim f as form1
f.showdialog()
f.getresults(id, date)

obviously f.getresults(id, date) wouldn't be called, but I do want the characteristics of the dialog in that I don't want the user to be able to move away from the form until it is closed.

Can I have the best of both worlds somehow?
0
Comment
Question by:DavidGreenfield
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
8 Comments
 
LVL 10

Expert Comment

by:Kinger247
ID: 17956285
Is there no reason why you cannot do it this way ?

f.getresults(id, date)
f.showdialog()
0
 
LVL 13

Expert Comment

by:newyuppie
ID: 17956439
a proper way of doing it would be handling the dialog close event from form1 and get the values there:

dim f as form1
AddHandler f.FormClosing, AddressOf f_closing
f.ShowDialog()


    Private Sub f_closing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs)
        Dim f As Form1 = DirectCast(sender, Form1)

        somevar = f.getresults(id, date)

    End Sub
0
 
LVL 13

Expert Comment

by:newyuppie
ID: 17956443
excuse me not from form1, i meant from the form that calls the form1
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:DavidGreenfield
ID: 17956522

Yes it is a little bit more compilcated that I have explained.

I have a generic "pop up" form with all the graphics in.  and I call a sub in this to load any form I want.

Sometimes the form I am loading needs to run a sub, where I tell the pop up not to load as dialog so I am able to do this.  What I really want is either to be able to switch the dialog on, or to mimick the dialog action.

so actually:

dim f as form1
popup.load(f,false) - where false means no dialog
f.getresults(id, date)
0
 
LVL 13

Accepted Solution

by:
newyuppie earned 2000 total points
ID: 17956523
what i posted is the proper way if you need to retrieve values, obviously when displayed dialog has started to close, and still has the variables in memory.
if you need to run a sub when the form is loading you can pretty much hook to any event in the dialog.

dim f as form1
AddHandler f.Load, AddressOf f_load
f.ShowDialog()

etc
0
 
LVL 13

Expert Comment

by:newyuppie
ID: 17956557
maybe write your own Show sub, so inside the dialog you could have something like:
public shared sub MyShow(byval boolDialog as boolean)
  dim f as new form1
  if boolDialog then
    f.showdialog
  else
    f.show
  end if
end sub

and call from your popup
f.MyShow(true) or f.MyShow(false)
0
 

Author Comment

by:DavidGreenfield
ID: 17956982
hi newyuppie,

your method does work, I had to change my code slightly - but it is now working.

Thank you very much!
0
 
LVL 13

Expert Comment

by:newyuppie
ID: 17957010
you're welcome, thanks for the points
NY
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question