inm101 Posted August 3, 2009 Share Posted August 3, 2009 What's the best way to convert a string to an int and an int to a string? Link to comment Share on other sites More sharing options...
Valuater Posted August 3, 2009 Share Posted August 3, 2009 One way... $string = String(10) MsgBox(4096, "Test", $string) $string2 = "10" MsgBox(4096, "Test", Int($string2)) 8) gwinter 1 Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted August 3, 2009 Share Posted August 3, 2009 You mean String() and Int() ? .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
Info Posted August 3, 2009 Share Posted August 3, 2009 int() string() Link to comment Share on other sites More sharing options...
inm101 Posted August 3, 2009 Author Share Posted August 3, 2009 One way... $string = String(10) MsgBox(4096, "Test", $string) $string2 = "10" MsgBox(4096, "Test", Int($string2)) 8) Didn't know it was that straight forward. Thanks for your help. Link to comment Share on other sites More sharing options...
maniootek Posted November 12, 2014 Share Posted November 12, 2014 (edited) what if my int looks like "10,123"? how to get same looks string? $str = "10,123" Int($str) ; return "10" instead of "10,123" Edited November 12, 2014 by maniootek Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted November 12, 2014 Moderators Share Posted November 12, 2014 1. I commend you in searching for an answer before you posted. 2. However, please be mindful of the date of threads you post in, this thread was 5 years old and is considered necroposting. 10 comma 123 isn't a number is it? It's a "formatted" number" "string". $str = "10,123.56" ConsoleWrite(_IntFromString($str) & @CRLF) Func _IntFromString($s_str) ; strip non digit from string Return Int(StringRegExpReplace($s_str, "[^\d\.]", "")) EndFunc Try that. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Recommended Posts