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

Open a Form (showdialog) but run code in the background

Hi,

I have a VB.net project which consists of one main Form with about 5 buttons on.

When clicking on a button, this will open another Form using the button_click Sub. What I would like it to do is open the form but run a macro in the background and then close the form. The form is a kind of splash screen, a "waiting" message while code is running so it will be called multiple times from all of the buttons in the main form. For example, this is my code...

Expand|Select|Wrap|Line Numbers
  1. Private Sub Button1_Click(sender As Object, e As EventArgs) Handles butCancel.Click
  2.  
  3.   ConnectionForm.ShowDialog()
  4.   Call Macro1()
  5.   ConnectionForm.Dispose()
  6.  
  7. End Sub
  8.  
The problem I have is that the ConnectionForm (this is the "welcome" message) opens, but doesn't run the Macro1.

I could put Macro1 inside the ConnectionForm_Load sub, but it will be a generic welcome message and it doesn't want to run the same macro every time it opens.

Anyone come across this before and have a simple solution?
Oct 23 '13 #1
2 2674
!NoItAll
297 100+
Use form.show rather than form.showdialog.
Make sure the macro does not return until you are ready for the form to close - otherwise you need to use threading.thread.sleep after the macro...
Oct 27 '13 #2
Blooming heck, is it really that simple? I can't believe I missed that one!!! Thank you so much for your help.

Can you advise though how I get this ConnectionForm.Show to actually show in the CenterParent rather than just the top left? The ShowDialog always shows it as the CenterParent when using the "StartPosition" property, but Show seems to ignore this.
Oct 28 '13 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: peshrad | last post by:
Hi ! Is there anybody who knows (if possible, by theory and practice) what sense it makes to hand over an owner to Form.ShowDialog ? I cannot close/minimize the owning window while the dialog...
3
by: LiFo | last post by:
how to open an form in an thread and pass an object in the constructor ??
3
by: Ivan Weiss | last post by:
I have been using form.show to display my forms yet I see a lot of people using form.Showdialog. What are the differences and when is one better than the other or are they the same...? -Ivan...
4
by: Jm | last post by:
Hi all Im not sure of the best way to be displaying my forms and just want a bit of clarification. Being only recently moved to vb.net im still used to the old vb6 form.show method, now under...
2
by: allyn44 | last post by:
Hello, I have built a serch form for users to edit records. I only want them to pull up the record they need, and I want to check for nulls. There should not be dupes becasue the underlying...
2
by: AS | last post by:
Hi, I have a windows form with a background image - set through the forms background image property. The form also has panels and icons on top of it. When this form is loading, there's a...
14
by: keri | last post by:
Hi, Simple version of the question..... How do I use the where clause of the open form command to show an account with a matching ID to be displayed when the form is opened? Eg. I select a...
1
by: Frank Rizzo | last post by:
I am not grokking the difference between Form.ShowDialog() and Form.ShowDialog(this). I have a form (parent form) that kicks off a modal dialog using Form.ShowDialog(). The modal dialog has a 3rd...
2
by: Jetean | last post by:
Hi: I search through this forums and google around about this Form.ShowDialog(): I'm unable to make the event at Child Form stop running and It looks like the child Form is still "Alive": ...
3
by: kayo | last post by:
how to run a form in the background.i need to run a form where it appears until the application exit. on top of that form(Main), another form(Main1) runs. how can i implement this using C#? ...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.