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. How to assign text control's value to a numeric variable?

How to assign text control's value to a numeric variable?

Scheduled Pinned Locked Moved C#
questioncsharpdotnetvisual-studiohelp
4 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.
  • A Offline
    A Offline
    Amol Ravatale
    wrote on last edited by
    #1

    Hi All, How can I assign a Text control's Text value to a numeric datatype. If I do like this double temp = Text1.Text gives compile time error. In case if I cast as follows double temp=(double) Text1.Text gives run time error as invalid cast. Some body had suggested me to use TryParse() ot Parse method of numeric data type. But I do see any method for numeric data type namely TryParse() or Parse(). I have .NET Framework 1.1 and VS 2003. Regards, Amol

    Every thing will come to you if you have faith.

    S E B 3 Replies Last reply
    0
    • A Amol Ravatale

      Hi All, How can I assign a Text control's Text value to a numeric datatype. If I do like this double temp = Text1.Text gives compile time error. In case if I cast as follows double temp=(double) Text1.Text gives run time error as invalid cast. Some body had suggested me to use TryParse() ot Parse method of numeric data type. But I do see any method for numeric data type namely TryParse() or Parse(). I have .NET Framework 1.1 and VS 2003. Regards, Amol

      Every thing will come to you if you have faith.

      S Offline
      S Offline
      Stefan Troschuetz
      wrote on last edited by
      #2

      In Framework 1.1 there's no TryParse but a Parse method.

      double temp = Double.Parse(Text1.Text);


      "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook

      www.troschuetz.de

      1 Reply Last reply
      0
      • A Amol Ravatale

        Hi All, How can I assign a Text control's Text value to a numeric datatype. If I do like this double temp = Text1.Text gives compile time error. In case if I cast as follows double temp=(double) Text1.Text gives run time error as invalid cast. Some body had suggested me to use TryParse() ot Parse method of numeric data type. But I do see any method for numeric data type namely TryParse() or Parse(). I have .NET Framework 1.1 and VS 2003. Regards, Amol

        Every thing will come to you if you have faith.

        E Offline
        E Offline
        engsrini
        wrote on last edited by
        #3

        try Convert.ToDouble(str); method

        1 Reply Last reply
        0
        • A Amol Ravatale

          Hi All, How can I assign a Text control's Text value to a numeric datatype. If I do like this double temp = Text1.Text gives compile time error. In case if I cast as follows double temp=(double) Text1.Text gives run time error as invalid cast. Some body had suggested me to use TryParse() ot Parse method of numeric data type. But I do see any method for numeric data type namely TryParse() or Parse(). I have .NET Framework 1.1 and VS 2003. Regards, Amol

          Every thing will come to you if you have faith.

          B Offline
          B Offline
          BlackDice
          wrote on last edited by
          #4

          double.Parse(Text1.Text)

          My Music | My Pics | My Articles BlackDice

          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