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

close automatically a form

Straight forward action though ... I tkink it's not. I create a form
(as a custom messagebox) with just one label on it. Using
System.Threading.Thread.Sleep(3000) does the job but the label text is
not shown during these 3 seconds. After the Sleep instruction the label
text is shown but is unreadable since I close the form after the
"sleep". Using the "Sleep" method during the Closing Event of the form
(and thus not in the function used) doesn't solve the problem. Any
ideas ?

This is the code used:

Private Function ShowSuccessMessageBox()
Dim message As String
Dim w As Int16
Dim h As Int16

fMsgbox = New Form
lblMessage = New Label

message = "Email and possible attachments successfully saved."
w = message.Length

With lblMessage
.BackColor = Color.Green
.ForeColor = Color.White
.Font = New Font("Arial", 10, FontStyle.Bold)
.Location = New Point(15, 25)
.Width = w * 7
.Text = message.ToString
End With

w = 375
h = 100
With fMsgbox
.Controls.Add(lblMessage)
.CausesValidation = False
.StartPosition = FormStartPosition.CenterScreen
.BackColor = System.Drawing.Color.Green
.MinimumSize = New System.Drawing.Size(w, h)
.MaximumSize = New System.Drawing.Size(w, h)
.MinimizeBox = False
.MaximizeBox = False
.Text = "Successful Save"
.Show()
End With
System.Threading.Thread.Sleep(3000)
fMsgbox.Close()
fMsgbox = Nothing
End Function

Apr 11 '06 #1
2 2172
Hello, DotNetter,

Try adding:

Application.DoEvents()

directly before:

System.Threading.Thread.Sleep(3000)

Cheers,
Randy
dotnetter wrote:
Straight forward action though ... I tkink it's not. I create a form
(as a custom messagebox) with just one label on it. Using
System.Threading.Thread.Sleep(3000) does the job but the label text is
not shown during these 3 seconds. After the Sleep instruction the label
text is shown but is unreadable since I close the form after the
"sleep". Using the "Sleep" method during the Closing Event of the form
(and thus not in the function used) doesn't solve the problem. Any
ideas ?

This is the code used:

Private Function ShowSuccessMessageBox()
Dim message As String
Dim w As Int16
Dim h As Int16

fMsgbox = New Form
lblMessage = New Label

message = "Email and possible attachments successfully saved."
w = message.Length

With lblMessage
.BackColor = Color.Green
.ForeColor = Color.White
.Font = New Font("Arial", 10, FontStyle.Bold)
.Location = New Point(15, 25)
.Width = w * 7
.Text = message.ToString
End With

w = 375
h = 100
With fMsgbox
.Controls.Add(lblMessage)
.CausesValidation = False
.StartPosition = FormStartPosition.CenterScreen
.BackColor = System.Drawing.Color.Green
.MinimumSize = New System.Drawing.Size(w, h)
.MaximumSize = New System.Drawing.Size(w, h)
.MinimizeBox = False
.MaximizeBox = False
.Text = "Successful Save"
.Show()
End With
System.Threading.Thread.Sleep(3000)
fMsgbox.Close()
fMsgbox = Nothing
End Function

Apr 11 '06 #2
So simple but also very effective. It works just fine. Thanks a lot for
this solution.

Dirk

Apr 11 '06 #3

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

Similar topics

7
by: Nikki | last post by:
Hi, Can anybody help me, i want to prevent windows to close my winform of ..NET application, when user presses Alt+F4
2
by: Paul | last post by:
Hi this is related to a previous post, hopefully just a bit clearer description o the problem. I have a parent form that opens a new form (child form) while still leaving the parent form open....
1
by: Adam Honek | last post by:
Why oh why has MS changed so much in VB.NET I can't even figure out how to show/close a form as formname.show() doesnt work and the following doesn't either: formname.activeform.close() (or...
10
by: morangolds | last post by:
Hi, I've been having a problem with C++ Windows Forms apps not "ending" when you close the form window. I've searched about this problem all over the place and most searches have lead me to...
4
by: polocar | last post by:
Hi, I would like to find a way in C# so that, when the user presses the "Esc" key, the form closes; the problem is that I have a lot of controls in the form. At the beginning I have tried with...
8
by: mattgcon | last post by:
I have a popup form within my application that I want to show for only about 10 seconds. On this form by the way has an AVI that plays. I want the form to popup on click of a button and close after...
2
by: Del | last post by:
I have a popup form that consist of a single field called EnteredBy and a Subform that has three fields. The popup form also has a button in the Form Footer called close. In the On Click event I...
7
by: sumanta123 | last post by:
Dear All, How will we do in JSP page on closing the parent window the child windows should close automatically. I will show my code Please i will show you my code. For HTML link function...
15
by: Bud Toye | last post by:
I use a macro to open a form, copy information from one of the fields, paste that information elsewhere, then go to the next record and do the same again. This procedure works perfectly until the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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.