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. C#
  4. Passing value from the form

Passing value from the form

Scheduled Pinned Locked Moved C#
helpquestion
7 Posts 3 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.
  • V Offline
    V Offline
    Verghese
    wrote on last edited by
    #1

    When I'm using the following code, everything is Okay.

    DateTime startDate = DateTime.Parse("05/01/2007");
    DateTime endDate = DateTime.Parse("06/01/2007");

    But when I try to pass the date value directly from the text box, it gives me error. How can I pass the date directly into the code from textbox. Any suggestions. Thanks

    W P 2 Replies Last reply
    0
    • V Verghese

      When I'm using the following code, everything is Okay.

      DateTime startDate = DateTime.Parse("05/01/2007");
      DateTime endDate = DateTime.Parse("06/01/2007");

      But when I try to pass the date value directly from the text box, it gives me error. How can I pass the date directly into the code from textbox. Any suggestions. Thanks

      W Offline
      W Offline
      Wendelius
      wrote on last edited by
      #2

      DateTime startDate = DateTime.Parse(textBox.Text); :confused: If that doesn't work, what's the error

      V 1 Reply Last reply
      0
      • V Verghese

        When I'm using the following code, everything is Okay.

        DateTime startDate = DateTime.Parse("05/01/2007");
        DateTime endDate = DateTime.Parse("06/01/2007");

        But when I try to pass the date value directly from the text box, it gives me error. How can I pass the date directly into the code from textbox. Any suggestions. Thanks

        P Offline
        P Offline
        Pete OHanlon
        wrote on last edited by
        #3

        Try putting the value from the textbox into a temporary variable and see what it is by debugging your application. Also, try to read the exception that has been thrown to see what it is.

        Deja View - the feeling that you've seen this post before.

        My blog | My articles

        V 1 Reply Last reply
        0
        • W Wendelius

          DateTime startDate = DateTime.Parse(textBox.Text); :confused: If that doesn't work, what's the error

          V Offline
          V Offline
          Verghese
          wrote on last edited by
          #4

          It gives me a compile error : 'System.DateTime' does not contain a definition for 'Text'

          P W 2 Replies Last reply
          0
          • V Verghese

            It gives me a compile error : 'System.DateTime' does not contain a definition for 'Text'

            P Offline
            P Offline
            Pete OHanlon
            wrote on last edited by
            #5

            Eh? This would say that you were using the DateTime and not the TextBox.

            Deja View - the feeling that you've seen this post before.

            My blog | My articles

            1 Reply Last reply
            0
            • V Verghese

              It gives me a compile error : 'System.DateTime' does not contain a definition for 'Text'

              W Offline
              W Offline
              Wendelius
              wrote on last edited by
              #6

              With the code I posted??? I think that you have mismatched parenthesis or something else. Could you post your code that generates the error

              1 Reply Last reply
              0
              • P Pete OHanlon

                Try putting the value from the textbox into a temporary variable and see what it is by debugging your application. Also, try to read the exception that has been thrown to see what it is.

                Deja View - the feeling that you've seen this post before.

                My blog | My articles

                V Offline
                V Offline
                Verghese
                wrote on last edited by
                #7

                This was exactly what I tried b4 posting. I stored the value from textbox into a String variable and then Parsed it into DateTime as it's shown in the code. But all this time I was getting errors b'coz the name of my Textbox was same as that of the variable I used for used for storing the date. So, I changed the variable name and its UP and RUNNING. Thanks a lot to everyone :)

                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