CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2002
    Location
    Mumbai
    Posts
    98

    Smile What the equivalent of the Val (VB.Net) function in C#

    Hi,

    I am trying to do multiplication of the two double number from the textbox.

    It is giving me FormatException for the blank textbox and if the textbox is having purely string value.

    Code is like this

    double temp = double.Parse(txtLI_JobsAffected3.Text) * double.Parse(txtLI_Impact3.Text);

    txtLI_Total3.Text = System.Convert.ToString(temp);


    Can anybody tell me how to deal with this?

    I am new to C#.

    Anyhelp will be appreciated.

    Thanks
    Amit

  2. #2
    Join Date
    Jun 2006
    Location
    http://jobble.org/map?rid=5110
    Posts
    8

    Lightbulb Re: What the equivalent of the Val (VB.Net) function in C#

    try this:

    double temp;
    try
    {
    temp = double.Parse(textBox1.Text) * double.Parse(textBox2.Text);
    textBox3.Text = temp.ToString();
    }
    catch
    {
    textBox3.Text = "fields empty or input is not_a_number";
    }


    (sorry for plain text)
    take care
    \me is new too

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

Featured