Passing in variables

This is a discussion on Passing in variables within the C# Programming forums, part of the General Programming Boards category; In my GUI I've got two textboxes. I'd like to take the numbers from the textboxes and perform a calculation ...

  1. #1
    Registered User CompiledMonkey's Avatar
    Join Date
    Feb 2002
    Location
    Richmond, VA
    Posts
    438

    Passing in variables

    In my GUI I've got two textboxes. I'd like to take the numbers from the textboxes and perform a calculation on them. But when you take a number in from the textbox it comes in as a string, not a double. How can I convert the value to a double so I can perform a calculation on them? Thanks alot.

  2. #2
    Something Clever ginoitalo's Avatar
    Join Date
    Dec 2001
    Posts
    187
    Not tested but,

    Try,
    NumberBox n1=new NumberBox();

    Instead.

    Let me know, post some code so we can get this forum active !

  3. #3
    Registered User CompiledMonkey's Avatar
    Join Date
    Feb 2002
    Location
    Richmond, VA
    Posts
    438
    I found it a little bit ago. MS was very nice to give us some methods to do it for us.

    Code:
    x = System.Convert.ToDouble(txtValue1.Text);
    y = System.Convert.ToDouble(txtValue2.Text);

  4. #4
    Something Clever ginoitalo's Avatar
    Join Date
    Dec 2001
    Posts
    187
    That's what I'm finding alot with the framework,

    It's all there you just have to find it, I think we'll be
    writing less of our own "conversion & parsing" functions.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problems passing values from function to main variables
    By ERJuanca in forum C Programming
    Replies: 18
    Last Post: 06-12-2009, 08:13 PM
  2. Passing variables to a subroutine
    By shaig in forum C Programming
    Replies: 5
    Last Post: 03-16-2009, 07:21 PM
  3. C# in ASP.Net - Passing complex variables
    By Llam4 in forum C# Programming
    Replies: 3
    Last Post: 01-19-2008, 02:53 AM
  4. question on passing variables
    By dirgni in forum C++ Programming
    Replies: 5
    Last Post: 12-04-2002, 04:36 PM
  5. functions to return 2 variables?
    By tim in forum C Programming
    Replies: 5
    Last Post: 02-18-2002, 02:39 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21