How to make a message pop up based on a date user selected? - vb.net

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.

Related

How to Repeat Saving my Powerpoint file every 5 minutes?

I've been wanting to write a macro to automatically save my powerpoint file every 5 minutes. Can anyone help?
I know there's an auto-save built-in but that's only good for auto recover. I'm attempting to have this ppt being saved every 5 mins so that other users using it at the same time will see the updates come in (using Office 365).
Thanks!
I don't think you'll be able to do this with a simple macro, but you might be able to make it work with an add-in.
The add-in would:
Trap events, specifically the SelectionChanged event.
Every time the event fires, the event handling code compares the current time to the time it last fired (stored in a static variable).
If more than x minutes have elapsed since the event last fired, saves the presentation and resets the last-fired time.
If the event never fires during a session, it means that nothing changed, so no real reason to save.
A further refinement: before or after checking the time difference, check the presentation's .Saved property. If True, then nothing has changed in the presentation, so again, no reason to save.
I could be wrong, but most answers I've seen regarding saving in intervals use the OnTime method. This isn't actually available in PowerPoint, so I'm not actually sure that what you're wanting to do is possible.

Disable a page in VB.net for a particular time

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

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.

Masked Text Box removes preceeding zeros in date

I have a process which grabs the birthdate and from a data table and display them in a masked text box for viewing and editing
However when pushing the data into the textbox any preceding zeros get removed
For example 05/05/2005 would display as 55/20/05__
The masked Text box is set up as 00/00/0000
The line which assigns the code is:
MaskedTextBox.Text = Format(DataTable(0)("DOB"), “MM/dd/yyyy”).ToString
To date I have tried the following:
Delete and re-add the control
Copy masked textbox from another form
in the same program
Above Masked textbox grabs the same
information from the same database
table and is formatted exactly the
same and it works
Tried various different formats
including no format all with the same
result
Does anyone have any other suggestions?
I've been able to replicate the problem but currently there doesn't seem to be a solution. What you need is a binding navigator toolbar on the top of your form with your data bound masked text box with any mask (doesn't matter which one). When you run the form, initially the masked text box will accept the data just fine. However, if you click the "AddNewItem" button (the plus sign button) on your binding navigator toolbar, it will cause the masked text box to delete all preceding zeros when you try to enter a date. It seems all masks will do this. Rebuilding the form won't fix it, either. It happens every time you hit the "AddNewItem" button and then proceed to enter data into any formatted masked text box.
Now that I've found out exactly how to replicate the problem, hopefully someone more knowledgeable can come along to figure out how to circumvent this. It seems like it is a glitch within VB. Don't know if this constitutes as an actual "answer" but I have provided a clear path to finding a solution. I just don't have the know-how to get that far.
(Update: I discovered that it does this to all masks, not just "short date" masks)
I think I am going to have to put this in "Mysteries of the Unexplained " box.
At the advice of another developer I manually recreated the form, re-added all the controls and it now works fine (copy and pasting all the controls from one form to another caused the issue to come with it).
I really don't know how to even recreate the issue must be something in the forms design level code???
Anyway thanks for all the assistance from everyone.
Try converting the Datatable data to date and back:
MaskedTextBox.Text = Date.Parse(DataTable(0)("DOB")).ToString("MM/dd/yyyy")
My guess is that either the database is sending the date in a format you don't expect, you changed the control's Culture (under Behaivior properties), or that you changed the way your computer shows dates and thus changed its culture. However I try I can't replicate the problem with my culture settings.
I had the same problem with Masked a Text Box control that was added at runtime. I was just trying to add the date of the day to the control
Visual studio 2013
Dim Today As Date = Now.Date
tbox_ShipDate.Text = FormatDateTime(Today,DateFormat.ShortDate) 'Failed every time
Problem was solved by using
tbox_ShipDate.Text = Format(Today, "MM/dd/yyyy")
seemed to simple but all worked well