Disable a page in VB.net for a particular time - vb.net

Im trying to disable a page which is opened while clicking a hyperlink in my application. My application is developed using VB.Net.
Can we use Timer function?

There are several ways to display a maintenance notification message. My preferred method is to use a database table called MaintenanceNotification.
Then, when you load the page, check the database for an existing notification, if there is one, handle appropriately.
**MaintenanceNotification**
MaintenanceNotificationId
StartDate
EndDate
Message
Comments
EDIT
To show a message at the same time every day, when the page loads, compare DateTime.Now.TimeOfDay to the time you want the messaged displayed (use a TimeSpan).
Psuedo Code:
If DateTime.Now.TimeOfDay is >= start time AND ALSO DateTime.Now.TimeOfDay <= end time THEN
'display the message.
END IF

Related

How to make a message pop up based on a date user selected?

So I am doing a reminder tool in Visual Basic for myself and I added a MonthCalendar to the windows (check image). It runs great. User writes down the name and a date (in 24 hour format for now) and then when you click the add reminder, it registers it into the listbox and also writes it into a file so when user closes and opens the application, it stays there. When the time in my PC coincides with the one in the program, a message pops up. The only thing left I'm having trouble is with dates.
I want to be able to choose a date and a message popping at that day with the time. I know it might be simple, but for some reason I can't think of a way and searching around didn't help me.
Here's a snippet of the code I have for when the time coincides:
If (TimeValue(Now) = time) Then 'Dim time As String = l.Substring(0, 9)
MsgBox(msg)
End If
I thought using an If statement similar to this would work, but it tells me that dates really don't go well with boolean and I tried looking around the subfunctions, but I've yet to find any.
To be clear: The only thing I need is to be able to register the date. Here's an image of the designer view.
Design View
Use a Timer. Calculate how many milliseconds there are until the event and set the Interval of the Timer to that value. The maximum Interval value gives you just over 24 days. If you need more than that then simply set the Interval again when the Tick occurs. You keep going in jumps of ~24 days until you get to the event.

How to manage event for made a load bars in Access

I created an application with Access (2013) with VBA. This application crawls a website and inserts some records into database. But it takes too much time.
My solution is to make load bars for waiting. But currently I use the event Form_Current(); and when I set the load bar's value (it's my function) setBarLoadValue (25) Nothing is displayed on the screen. Why ? Because my function run yet.
My question is: How I can manage the event to simulate a load bar in real time ? (Don't want to wait till the end of function to see 100%).
The following link has a beautifully designed Progress status bar. http://www.access-programmers.co.uk/forums/showthread.php?t=265537
The author of the code has provided a Class where you have a Form that acts as a Meter and you basically set the values. It could be real time enough, have a look. I use it in my application and works great.
Finally I found an solution !
Solution
Step1
You must enter this code in your code
DoCmd.SelectObject acForm, Me.Name
Me.Repaint
DoEvents
With this code, you display immediately the form
Step 2
Now, when you want to display something, you must just do that: DoEvents.
When you use DoEvents the form refresh and you can display the new state of the progress bar.
Note: This solution work with Access 2013. Maybe it's not supported with other version.

Keep VB.NET application running in the background after base form closed

I am writing an application in VB.Net in which a user can schedule emails to be sent in the future. Is there a way to keep my listener thread running in the background after the base form on the application is closed? I would also need to start up the listener when the system boots, but wouldn't want any forms to open at that time.
Example (desired) functionality: I open the application in the morning and schedule three emails, one of which should be sent in three hours, and the other two of which should be sent tomorrow morning. I close the application. In three hours, the first one sends. At the end of the day, I shut down my machine. When I turn it back on tomorrow morning, the other two are sent without me ever opening the application.
I am thinking I need to separate the listener into a service, but want to make sure there isn't an easier way before going down that road.
If I do end up having a separate service and application, can I create an installer that will install both at once?
In the options of your project, set the “Startup Object” to “Sub Main” instead of of a form name. You might have to disable the setting “Application Framework” first.
Now you have to launch the form manually because it’s no longer done automatically, but on the other hand you can now control when to launch it, and your application will exit when it reaches the end of the Main method (or when it’s quit explicitly) rather than when the form closes.
If all you want is to keep the program running, you could supply it with the definition for a TaskBar icon, and represent state in your application using the icon's graphic. It would appear over on the right next to the system clock.
Then it's just a matter of reconfiguring your development project so that the application close event is triggered off that icon's menu instead of off the fact that the form is closed.
Use a NotifyIcon control and when the user close the mainform capture the OnClosing Event to Ask the Question if he want to minimize to the tray or exit the application.
Here is the documentation of NotifyIcon control from Microsoft:
NotifyIcon Control
I have a possible solution for you here. In the form closing event you can place the following code:
Private Sub Form1_FormClosing(sender As Object, e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
Me.Visible = False
e.Cancel = True
End Sub
This will hide the form and allow it to run in the background until you shutdown the computer. To handle the restart and then send emails I'd suggest adding the emails to be sent to a text file that can be accessed after restart and then adding the program to startup. An even better solution might be to have 2 programs, one that is on startup and is always hidden that checks the text file every 15 minutes (for example) and a second program that is launched when a new email is to be added to the list and it appends the text file with new emails to be sent.
(Sorry if i am wrong, just proposing a probable solution here)
I think attaching a simple db to hold the email sending schedule information/date-time and loading the application at startup with Notification Icon (or without Notification Icon but with a shortcut to show user interface/form to feed the emails and schedule information/date-time, if required + BackgroundWorker, if you want the application to go to sleep mode and wake it later to send first scheduled email; after X hours). After sending first email update the db then exit the application. Check the db on startup to send the first email or go to sleep mode if pc boots before sending first email. But, if first email is already sent then send other two scheduled emails (check db date-time). This should do the job...
:)

How To Correctly Display A Dialog Box During Long Processing - VB.NET

Running into a situation when user searches for orders of customer for past 4 years. As the DB query takes a long time, I want to show a pop up box just stating 'please wait. quering for results'. so when they start their search I want to show the message box until the results are obtainned and at that point I want to close the message box.
My current way, I know is incorrect as the pop up box locks up and states (not responding).
Would using a background worker be an over kill, or should I go with a progress bar?
My current way:
Dim frmProcessing As New ShowWaitForm
'/ set location to open the form
'/ set any custom message
frmProcessing.Show()
'//do db query and other stuff with result-> i CANNOT CHANGE THIS CALL NOR CAN I MODIFY HOW IT IS CALLED/FUNCTIONS
frmProcessing.Close()
frmProcessing = Nothing
I personally find the background worker to be a better choice most of the time. It allows me some more flexibility later if I want to add more information. I can use the ProgressChanged event to update a progress bar, and later if my needs change I can do other things as well.

Popup window / message for remaining time

I have several froms in my application. When application starts, a timer starts for 30 minutes.
I want to show the remaining time using a popup window, message or whatever, on whichever form the user is at that time.
Please advise how to do it.
Thanks
Furqan
The timer objects in the .net framework do not give access to the time already elapsed or remaining.
However when your application starts you will can create and start a stop watch.
private _sw as System.Diagnostics.Stopwatch = System.Diagnostics.Stopwatch.StartNew()
At any time you can then call the following code which you can subtract from your 30 minutes
_sw.Elapsed.TotalSeconds
To show this time constantly on a form you may need a second timer to update the screen that queries this value.