in Search
ATTENTION: I've decided to put the upgrade on hold due to a compatibility issue of our server environment with the latest CS installer package. CS 2008 now requires SQL Server 2005 as the backend DB but our database server currenlty has SQL Server 2000 installed on it. I'll resume the upgrade once I figure out when Telligent is releasing a patch to the schema compatibility issue. For now, we will continue to use the old version of CS while waiting for the said patch. If you have any questions about this process, please don't hesitate to post them on our forums and I'll answer them as soon as I can. Thanks for your patience and support guys! I'll let you know as soon as this is resolved. - Keith Rull
Latest post 07-08-2008 4:39 AM by wildquaker. 6 replies.
Page 1 of 1 (7 items)
Sort Posts: Previous Next
  • 05-04-2008 6:21 PM

    • jpgjuan
    • Top 75 Contributor
    • Joined on 08-29-2006
    • Posts 23
    • Points 440

    Convert string to integer

    This is my code:

    Dim strsample, x 

    strsample = label.text

     x = strsample + 1

     

    Error :Input string was not in a correct format.

     Please help to convert label.text to integer

    Thanks in advance 

    • Post Points: 50
  • 05-04-2008 7:18 PM In reply to

    • modchip
    • Top 10 Contributor
    • Joined on 02-09-2006
    • Ivalice
    • Posts 710
    • Points 10,110

    Re: Convert string to integer

    Filed under: ,
    • Post Points: 5
  • 05-04-2008 7:31 PM In reply to

    • lamia
    • Top 10 Contributor
    • Joined on 06-20-2006
    • Sampaloc, Manila
    • Posts 752
    • Points 13,110

    Re: Convert string to integer

    jpgjuan:

    This is my code:

    Dim strsample, x 

    strsample = label.text

     x = strsample + 1

     

    Error :Input string was not in a correct format.

     Please help to convert label.text to integer

    Thanks in advance 

     

     

    Dim strsample, x 

    strsample = Val(label.text)

     x = strsample + 1

     

     

     

    Convert limitations to great expectations... You are the creative force of your life...

    • Post Points: 5
  • 05-05-2008 10:46 AM In reply to

    • keithrull
    • Top 10 Contributor
    • Joined on 08-08-2005
    • San Diego, CA
    • Posts 1,956
    • Points 39,165

    Re: Convert string to integer

    You need to convert the value of label.Text to an numeric value first before you can use it in any mathematical expression.

    Use Convert.Int32 method to accomplish what you wanted

    http://msdn.microsoft.com/en-us/library/sf1aw27b.aspx

    devpinoy sig

    • Post Points: 20
  • 06-19-2008 9:03 AM In reply to

    • patrick
    • Top 50 Contributor
    • Joined on 01-30-2006
    • Posts 27
    • Points 435

    Re: Convert string to integer

    Hehehe, I'll do it in C#

    string lblTextBox1;

    int x, y;

    lblTextBox1 = Label1.text;

    try {

     x = int.Parse(lblTextBox1);

    } catch {

     throw new Exception("duh, whatever");

    }

    y = x +1;

     

     

    • Post Points: 20
  • 06-19-2008 11:03 PM In reply to

    • cruizer
    • Top 10 Contributor
    • Joined on 12-14-2005
    • Singapore
    • Posts 944
    • Points 22,590

    Re: Convert string to integer

     why not use the Int32.TryParse() or Int64.TryParse() methods? no need to catch for exceptions.

    http://devpinoy.org/blogs/cruizer
    Naglalayong buksan at palayain ang kamalayan ng Pinoy .NET developer
    • Post Points: 20
  • 07-08-2008 4:39 AM In reply to

    • wildquaker
    • Top 100 Contributor
    • Joined on 07-06-2008
    • Las Pinas
    • Posts 13
    • Points 95

    Re: Convert string to integer

    I agree with cruizer. Using Convert.ToInt32() causes exceptions when trying to convert non numerical format and decimal inputs. TryParse since it returns a boolean value can work around these exceptions.

    • Post Points: 5
Page 1 of 1 (7 items)