none
Auto message pop-up

    Question

  • I want a way to have my calendar appointments to automatically pop-up on the system when the set date for appointment is reached.

    I am able to set appointments on the calendar, and able to have a message "You have an appointment set for today" BUT ONLY displays the message when i manually click on the appointment app meaning someone has to click on the app everyday to see if there are appointments for that day which shouldn't be the case.

    How can the set appointment message automatically pop-up on the screen.

    Here is what I have done:

    Imports System.IO

     Public Class Appointment
        Dim r As MsgBoxResult
        Dim t As String

        Private Sub SetApp_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Dim m As MsgBoxResult
            t = AppCalendar.SelectionRange.Start.Month.ToString & AppCalendar.SelectionRange.Start.Day.ToString

            If Date.Today = AppCalendar.TodayDate And File.Exists(t & ".txt") = True Then

                m = MsgBox("You have appointment set for today, would you like to view?", MsgBoxStyle.YesNo)

                If m = MsgBoxResult.Yes Then
                    AppCalendar.Enabled = False
                    AppCalendar.Hide()
                    txtMsg.Enabled = True
                    txtMsg.Show()
                    txtMsg.Text = ""
                    btnSet.Enabled = True
                    btnSet.Show()
                    btnBack.Enabled = True
                    btnBack.Show()
                    txtMsg.Text = File.ReadAllText(t & ".txt")
                End If
            End If
        End Sub

        Private Sub AppCalendar_DateSelected(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DateRangeEventArgs) Handles AppCalendar.DateSelected
            t = AppCalendar.SelectionRange.Start.Month.ToString & AppCalendar.SelectionRange.Start.Day.ToString

            Try
                If File.Exists(t & ".txt") = True Then
                    AppCalendar.Enabled = False
                    AppCalendar.Hide()
                    txtMsg.Enabled = True
                    btnSet.Enabled = True
                    btnSet.Show()
                    btnBack.Enabled = True
                    btnBack.Show()
                    txtMsg.Text = File.ReadAllText(t & ".txt")
                Else
                    r = MsgBox("Enter appointment for this day?", MsgBoxStyle.YesNo)
                    If r = MsgBoxResult.Yes Then
                        Calendar.Enabled = False
                        Calendar.Hide()
                        txtMsg.Enabled = True
                        txtMsg.Show()
                        txtMsg.Text = ""
                        btnSet.Enabled = True
                        btnSet.Show()
                        btnBack.Enabled = True
                        btnBack.Show()
                    End If
                End If
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
        End Sub 
        Private Sub btnSet_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSet.Click
            Try
                If txtMsg.Text = "" Then
                    If File.Exists(t & ".txt") = True Then
                        File.Delete(t & ".txt")
                    End If
                End If
                If txtMsg.Text.Length > 0 Then
                    File.WriteAllText(t & ".txt", txtMsg.Text)
                End If
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
        End Sub

        Private Sub btnBack_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBack.Click
            txtMsg.Enabled = False
            txtMsg.Hide()
            btnSet.Enabled = False
            btnSet.Hide()
            btnBack.Enabled = False
            btnBack.Hide()
            AppCalendar.Enabled = True
            AppCalendar.Show()
        End Sub

    NOTE: Everything is working except the appointment messages can't automatically pop-up

    Friday, May 24, 2019 10:42 AM

All replies

  • I would recommend in this case to set a breakpoint into the code logic responsible for showing the popup and step through the code to determine the issue. While stepping through code hover over variables to see their values which should then determine if the logic is correct along with if events are firing or not.

    Using breakpoints

    https://docs.microsoft.com/en-us/visualstudio/debugger/using-breakpoints?view=vs-2019


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Friday, May 24, 2019 11:07 AM
    Moderator
  • I want a way to have my calendar appointments to automatically pop-up on the system when the set date for appointment is reached.

    I am able to set appointments on the calendar, and able to have a message "You have an appointment set for today" BUT ONLY displays the message when i manually click on the appointment app meaning someone has to click on the app everyday to see if there are appointments for that day which shouldn't be the case.

    How can the set appointment message automatically pop-up on the screen.

    Here is what I have done:

    Imports System.IO

     Public Class Appointment
        Dim r As MsgBoxResult
        Dim t As String

        Private Sub SetApp_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Dim m As MsgBoxResult
            t = AppCalendar.SelectionRange.Start.Month.ToString & AppCalendar.SelectionRange.Start.Day.ToString

            If Date.Today = AppCalendar.TodayDate And File.Exists(t & ".txt") = True Then

                m = MsgBox("You have appointment set for today, would you like to view?", MsgBoxStyle.YesNo)

                If m = MsgBoxResult.Yes Then
                    AppCalendar.Enabled = False
                    AppCalendar.Hide()
                    txtMsg.Enabled = True
                    txtMsg.Show()
                    txtMsg.Text = ""
                    btnSet.Enabled = True
                    btnSet.Show()
                    btnBack.Enabled = True
                    btnBack.Show()
                    txtMsg.Text = File.ReadAllText(t & ".txt")
                End If
            End If
        End Sub

        Private Sub AppCalendar_DateSelected(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DateRangeEventArgs) Handles AppCalendar.DateSelected
            t = AppCalendar.SelectionRange.Start.Month.ToString & AppCalendar.SelectionRange.Start.Day.ToString

            Try
                If File.Exists(t & ".txt") = True Then
                    AppCalendar.Enabled = False
                    AppCalendar.Hide()
                    txtMsg.Enabled = True
                    btnSet.Enabled = True
                    btnSet.Show()
                    btnBack.Enabled = True
                    btnBack.Show()
                    txtMsg.Text = File.ReadAllText(t & ".txt")
                Else
                    r = MsgBox("Enter appointment for this day?", MsgBoxStyle.YesNo)
                    If r = MsgBoxResult.Yes Then
                        Calendar.Enabled = False
                        Calendar.Hide()
                        txtMsg.Enabled = True
                        txtMsg.Show()
                        txtMsg.Text = ""
                        btnSet.Enabled = True
                        btnSet.Show()
                        btnBack.Enabled = True
                        btnBack.Show()
                    End If
                End If
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
        End Sub 
        Private Sub btnSet_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSet.Click
            Try
                If txtMsg.Text = "" Then
                    If File.Exists(t & ".txt") = True Then
                        File.Delete(t & ".txt")
                    End If
                End If
                If txtMsg.Text.Length > 0 Then
                    File.WriteAllText(t & ".txt", txtMsg.Text)
                End If
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
        End Sub

        Private Sub btnBack_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBack.Click
            txtMsg.Enabled = False
            txtMsg.Hide()
            btnSet.Enabled = False
            btnSet.Hide()
            btnBack.Enabled = False
            btnBack.Hide()
            AppCalendar.Enabled = True
            AppCalendar.Show()
        End Sub

    NOTE: Everything is working except the appointment messages can't automatically pop-up

    Hi,

    Try to put the Message Box directly to the "IF" Statement like this

    If Date.Today = AppCalendar.TodayDate And File.Exists(t & ".txt") = True Then
        
        If MsgBox("You have appointment set for today, would you 
          like to view?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes 
         Then
    
                    AppCalendar.Enabled = False
                    AppCalendar.Hide()
                    txtMsg.Enabled = True
                    txtMsg.Show()
                    txtMsg.Text = ""
                    btnSet.Enabled = True
                    btnSet.Show()
                    btnBack.Enabled = True
                    btnBack.Show()
                    txtMsg.Text = File.ReadAllText(t & ".txt")
                End If
              End If

    I think it will work

    Good Luck

     

    Regards From Egypt


    • Edited by Amr_Aly Friday, May 24, 2019 12:24 PM
    Friday, May 24, 2019 12:22 PM
  • Its giving the same results by clicking on the appointment app that's when the message pops-up.
    Friday, May 24, 2019 1:35 PM
  • Any example please on a timer?
    Friday, May 24, 2019 2:15 PM
  • Any example please on a timer?

    Hi,

    timer example:

    Public Class Form1
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    
            Dim t As Timer = New Timer With {.Interval = 100, .Enabled = True}
            AddHandler t.Tick, Sub()
                                   If Date.Today = AppCalendar.TodayDate And File.Exists(t & ".txt") = True Then
                                       t.Enabled = False
                                       If MsgBox("You have appointment set for today, would you 
          like to view?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
                                           AppCalendar.Enabled = False
                                           AppCalendar.Hide()
                                           txtMsg.Enabled = True
                                           txtMsg.Show()
                                           txtMsg.Text = ""
                                           btnSet.Enabled = True
                                           btnSet.Show()
                                           btnBack.Enabled = True
                                           btnBack.Show()
                                           txtMsg.Text = File.ReadAllText(t & ".txt")
                                       End If
                                   End If
    
                               End Sub
        End Sub
    End Class
    

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, May 27, 2019 2:02 AM
    Moderator