Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Converting text to date

Converting text to date

Scheduled Pinned Locked Moved Visual Basic
helptutorial
8 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    User 1593977
    wrote on last edited by
    #1

    Can someone help me out with this. I want to have the user enter a date in the textbox and then on LEAVE validate and convert it to gregorian format. Example: Enter 01011995 in the text box and return 01/01/1995 OR 1195 or 111995 The code below worked until last week when I rebuilt my system; now it no longer works and I can't seem to find a way of making it. dim mydate as string mydate = Format(Me.editHireDate.Text.ToString, "Short Date") Arnie

    C D 2 Replies Last reply
    0
    • U User 1593977

      Can someone help me out with this. I want to have the user enter a date in the textbox and then on LEAVE validate and convert it to gregorian format. Example: Enter 01011995 in the text box and return 01/01/1995 OR 1195 or 111995 The code below worked until last week when I rebuilt my system; now it no longer works and I can't seem to find a way of making it. dim mydate as string mydate = Format(Me.editHireDate.Text.ToString, "Short Date") Arnie

      C Offline
      C Offline
      cnurse
      wrote on last edited by
      #2

      Arnie, try this simple change... mydate = Format(cDate(Me.editHireDate.Text.ToString), "Short Date") Nursey

      U 1 Reply Last reply
      0
      • U User 1593977

        Can someone help me out with this. I want to have the user enter a date in the textbox and then on LEAVE validate and convert it to gregorian format. Example: Enter 01011995 in the text box and return 01/01/1995 OR 1195 or 111995 The code below worked until last week when I rebuilt my system; now it no longer works and I can't seem to find a way of making it. dim mydate as string mydate = Format(Me.editHireDate.Text.ToString, "Short Date") Arnie

        D Offline
        D Offline
        Dave Kreskowiak
        wrote on last edited by
        #3

        Like cnurse said, but why does everyone execute .ToString() on something that's ALREADY A STRING! A .Text property always returns a String. Can someone explain to me, the purpose of converting a String to a String? Sorry, one of my pet peeves. Oh! And using Me to death pisses me off to! It's completely unnecessary...

        mydate = Format(cDate(editHireDate.Text), "Short Date")

        RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

        C O 2 Replies Last reply
        0
        • D Dave Kreskowiak

          Like cnurse said, but why does everyone execute .ToString() on something that's ALREADY A STRING! A .Text property always returns a String. Can someone explain to me, the purpose of converting a String to a String? Sorry, one of my pet peeves. Oh! And using Me to death pisses me off to! It's completely unnecessary...

          mydate = Format(cDate(editHireDate.Text), "Short Date")

          RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

          C Offline
          C Offline
          cnurse
          wrote on last edited by
          #4

          Dave, LMAO! I have the same pet hates, but sometimes until somebody says "you don't need to" people's habits remain the same. I remember prefixing ME. in vb4 actually slowed it down coz the stupid environment even resolved the referemce too! so funny. Another one of my pet hates is people not coding with Option Strict. There are lots of others and so little time hahahaha Have a good XMAS mate. Nursey

          D 1 Reply Last reply
          0
          • D Dave Kreskowiak

            Like cnurse said, but why does everyone execute .ToString() on something that's ALREADY A STRING! A .Text property always returns a String. Can someone explain to me, the purpose of converting a String to a String? Sorry, one of my pet peeves. Oh! And using Me to death pisses me off to! It's completely unnecessary...

            mydate = Format(cDate(editHireDate.Text), "Short Date")

            RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

            O Offline
            O Offline
            OICU812
            wrote on last edited by
            #5

            Dave Kreskowiak wrote: Oh! And using Me to death pisses me off to! It's completely unnecessary... LMAO...But Intellisense makes it so useful to help remember all those names that I forget!

            D 1 Reply Last reply
            0
            • O OICU812

              Dave Kreskowiak wrote: Oh! And using Me to death pisses me off to! It's completely unnecessary... LMAO...But Intellisense makes it so useful to help remember all those names that I forget!

              D Offline
              D Offline
              Dave Kreskowiak
              wrote on last edited by
              #6

              :-D What? You can't remember your own object names!? RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

              1 Reply Last reply
              0
              • C cnurse

                Dave, LMAO! I have the same pet hates, but sometimes until somebody says "you don't need to" people's habits remain the same. I remember prefixing ME. in vb4 actually slowed it down coz the stupid environment even resolved the referemce too! so funny. Another one of my pet hates is people not coding with Option Strict. There are lots of others and so little time hahahaha Have a good XMAS mate. Nursey

                D Offline
                D Offline
                Dave Kreskowiak
                wrote on last edited by
                #7

                Well, Option Strict I don't have a problem with, because sometimes it goes get in the way. For example, you can't use any late binding with it turned on. It's very helpful to turn that off when you using WMI. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

                1 Reply Last reply
                0
                • C cnurse

                  Arnie, try this simple change... mydate = Format(cDate(Me.editHireDate.Text.ToString), "Short Date") Nursey

                  U Offline
                  U Offline
                  User 1593977
                  wrote on last edited by
                  #8

                  cnurse wrote: Arnie, try this simple change... mydate = Format(cDate(Me.editHireDate.Text.ToString), "Short Date") Nursey I appreciate the input. I used your idea/code (even took off the "ToString") and still *&*^*& What I'm getting in return is what has caused me to look at options, settings and so on... "Cast from string "01151995" to type 'Date' is not valid. Arnie

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups