Results 1 to 7 of 7

Thread: convert date to a number with vb.net

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2002
    Posts
    224

    convert date to a number with vb.net

    how can i convert date to a number with vb.net

    example in vb6:

    Private Sub Form_Load()
    Text1.Text = Date
    End Sub
    Private Sub Command1_Click()
    Dim num
    num = Format(Text1.Text, "0")
    Text2.Text = num
    End Sub


    thanking you in advance

    From:
    [email protected]

  2. #2
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    what is the output of that? I dont have VB6, it would be helpful if you give an example of the current date + the output on textbox2
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Aug 2002
    Posts
    224
    example of number:

    22/10/2003 = 37916

  4. #4
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    How are those numbers related?

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Aug 2002
    Posts
    224
    every number represent a date

    to convert the date of Today to a number:
    TextBox1.Text = Date.Today.ToOADate


    to convert the number to date:
    Dim num As Double
    num = Val(Trim(TextBox1.Text))
    TextBox2.Text = Format(Date.FromOADate(num),"dd/MM/yy")

  6. #6
    Junior Member
    Join Date
    Oct 2003
    Location
    MS
    Posts
    22
    Convert a date entered into TextBox1, into a number ...


    TextBox2.Text = Date.Parse(TextBox1.Text).ToOADate



  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Aug 2002
    Posts
    224

    Convert a date entered into TextBox1, into a number

    To skid2964

    excellent answer

    thank you very much

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