Results 1 to 4 of 4

Thread: [RESOLVED] database form

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2010
    Posts
    2

    Resolved [RESOLVED] database form

    Hello, I'm new in this stuff and I already need some help. I try to make a WFA for filling, reading etc. to a database. I want to compare 2 dates (actually 1 date is changed by 42 days) that are chosen by a user through a datetimepicker. After comparing the 2 dates the "newest" date has to show up in a non editable textbox. This Is my code (of course I have 2 subs for the datetimepickers as well).

    Code:
    Private Sub AwbdatumTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AwbdatumTextBox.TextChanged
            Dim DatumbinnenkomstDateTimePicker As DateTime
            Dim DatumbeschikkingDateTimePicker As DateTime
            Dim beschikking As DateTime
            beschikking = DateAdd("d", 42, DatumbeschikkingDateTimePicker)
    
            If DatumbinnenkomstDateTimePicker > beschikking Then
                Me.AwbdatumTextBox.Text = DatumbinnenkomstDateTimePicker.ToString("ddMMyyy")
    
            Else
                Me.AwbdatumTextBox.Text = beschikking.ToString("ddMMyyy")
            End If
        End Sub
    Thanks in advance

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,422

    Re: database form

    declare:

    vb Code:
    1. Dim DatumbinnenkomstDateTimePicker As DateTime
    2. Dim DatumbeschikkingDateTimePicker As DateTime

    at form level, then they'll be available in your dtp_valuechanged event (for setting) + your AwbdatumTextBox_TextChanged event (for comparing).

    at least i assume that's what you're asking?

  3. #3

    Thread Starter
    New Member
    Join Date
    Aug 2010
    Posts
    2

    Resolved Re: database form

    Thanks a lot that helped . I had also to change some of my code so now it looks like:
    Code:
    Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim beschikking As Date
            beschikking = DateAdd("d", 42, DatumbeschikkingDateTimePicker.Value)
    
            If DatumbinnenkomstDateTimePicker.Value > beschikking Then
                Me.AwbdatumTextBox.Text = DatumbinnenkomstDateTimePicker.Value.ToString("dd-MM-yyyy")
            Else
                Me.AwbdatumTextBox.Text = beschikking.ToString("dd-MM-yyyy")
    
            End If
    
    
        End Sub
    As you can see I added a button, otherwise the textbox doesn't show the date. That's my next step, I want the textbox to show the date without pushing a button.

  4. #4
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,422

    Re: [RESOLVED] database form

    try this:

    vb Code:
    1. Private Sub DatumbinnenkomstDateTimePicker_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DatumbinnenkomstDateTimePicker.ValueChanged
    2.     Dim beschikking As Date
    3.     beschikking = DateAdd("d", 42, DatumbeschikkingDateTimePicker.Value)
    4.  
    5.     If DatumbinnenkomstDateTimePicker.Value > beschikking Then
    6.         Me.AwbdatumTextBox.Text = DatumbinnenkomstDateTimePicker.Value.ToString("dd-MM-yyyy")
    7.     Else
    8.         Me.AwbdatumTextBox.Text = beschikking.ToString("dd-MM-yyyy")
    9.     End If
    10.  
    11. End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width