Visual Basic > Visual Basic Forums > Visual Basic Language > Problems with Application settings
Ask a questionAsk a question
 

AnswerProblems with Application settings

  • Sunday, January 22, 2006 12:17 PMScorpFire Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Ok i got a problem with application setting.

    I have a textbox and a timer.
    The timer interval is 1000 so it ticks everys second.
    Under the timer event, if the textbox1.text shows todays date then it would display a msgbox
    So i bind the textbox with the application setting so everytime the text in the textbox is saved and loaded again

    This is the coding under the timer_tick event

    If textbox1.text = my.computer.clock.localtime.date then
       messagebox.show("Today is your day")
       End If


    Now the problem starts
    Because i bind the textbox with settings everytime form loads the textbox is empty, then i get an unhandled error because it does not match a date format

    If i assign the textbox.text to a date value like 01/01/2001, when form loads its empty again and i get the unhandled error

    Is there any way to make the textbox hold an initial value before the next value

     

     

Answers

  • Monday, January 23, 2006 12:06 AMKen TuckerMVP, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

     Why dont you use tryparse to check if you have a valid date

     

           Dim dt As Date
            If Date.TryParse(TextBox1.Text, dt) Then
                If dt = My.Computer.Clock.LocalTime.Date Then
                    MessageBox.Show("Today is your day")
                End If
            End If

     

     

All Replies

  • Monday, January 23, 2006 12:06 AMKen TuckerMVP, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

     Why dont you use tryparse to check if you have a valid date

     

           Dim dt As Date
            If Date.TryParse(TextBox1.Text, dt) Then
                If dt = My.Computer.Clock.LocalTime.Date Then
                    MessageBox.Show("Today is your day")
                End If
            End If