Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

converting ansistring to int

Options
  • 15-04-2003 9:39pm
    #1
    Registered Users Posts: 2,593 ✭✭✭


    i have this piece of code to take a value from an inputbox then convert it to an int then assign to a structure but it keeps telling me that i have clled an undefined function even thoughj i have included the vcl\dstring.h header file

    value is declared as an int

    AnsiString InputString = InputBox("Input Box", "Please enter the value for the gate", "0");
    value = ToIntDef(InputString);
    newconnector->Value = value;
    could any one help??

    tanx


Comments

  • Closed Accounts Posts: 3,322 ✭✭✭Repli


    try
    int value = ToIntDef(InputString);


  • Registered Users Posts: 2,593 ✭✭✭tommycahir


    sorry repli still getting the same error
    tanx for trying


  • Closed Accounts Posts: 3,322 ✭✭✭Repli


    Hmm k.. Try
    int value = InputString.ToIntDef(-1);
    This does the same thing iirc except if it tries to convert a string to an int it will return -1


  • Registered Users Posts: 6,240 ✭✭✭hussey


    int convert_ansi_int(AnsiString str) 
    {
    
    return atoi(str.c_str());
    
    }
    
    // this is equililebt of this (  I think)
    int convert_ansi_int(AnsiString str) 
    {
    
    char * tempStr = str.c_str();
    int num = atoi(tempStr);
    return num;
    
    }
    


Advertisement