Results 1 to 4 of 4

Thread: Convert String to an Integer

  1. #1

    Convert String to an Integer

    How can I convert a string to an integer?

    (I can only convert a integer to a string using the following code:
    String := Integer.ToString

    Thank you in advance..........

  2. #2
    SillyMember
    Join Date
    May 2003
    Location
    Gent
    Posts
    7,725
    Code:
    var
      S: string;
      I: Int32;
      J: integer;
    begin
      S := '12345';
      I := Int32.Parse(S);
      J := Int32.Parse(S);
      MessageBox.Show(S.Format('{0}{1}{2}',I, #13, J)+ #13 + S)
    end;
    All methodologies are based on fear. -- Kent Beck.

  3. #3
    Is er een voordeel van deze methode boven de System.Convert class (System.Convert.ToInt32) Dirk? Dat was de eerste waar ik aan dacht, maar ik weet niet of het één beter is dan het ander.
    Marcel

  4. #4
    SillyMember
    Join Date
    May 2003
    Location
    Gent
    Posts
    7,725
    .Parse neemt enkel een string als argument (en is dus het tegenovergestelde van .ToString). Convert doet zowat alle primitive types.
    System.Convert.ToInt32(String) roept overigens Integer.Parse op
    All methodologies are based on fear. -- Kent Beck.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. NLDSimpleIniFile
    By Dany in forum NLDDanyUtils
    Replies: 4
    Last Post: 14-Oct-17, 16:45
  2. NLDSimpleRegistry
    By Dany in forum NLDDanyUtils
    Replies: 8
    Last Post: 14-Oct-17, 16:45
  3. NLDRcsStrings
    By Dany in forum NLDDanyUtils
    Replies: 24
    Last Post: 14-Oct-17, 16:41
  4. Planprobleem
    By Ron1 in forum Koffiehoek
    Replies: 32
    Last Post: 09-Jan-05, 00:49
  5. Grote integers?
    By Tharkis in forum Algemeen
    Replies: 6
    Last Post: 09-Jun-03, 18:52

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •