O ovt001 Member Licensed User Longtime User Dec 18, 2012 #1 Hi boys, sorry for my stupid question, but I forgot how to convert a string to an integer with b4a. I made a EditText object but I need to use it to make a Socket connect. Problem is that the TCP port must be an Int.... thank you O.
Hi boys, sorry for my stupid question, but I forgot how to convert a string to an integer with b4a. I made a EditText object but I need to use it to make a Socket connect. Problem is that the TCP port must be an Int.... thank you O.
Erel B4X founder Staff member Licensed User Longtime User Dec 18, 2012 #2 Strings are converted automatically: Code: Dim i As Int = EditText1.Text You can use IsNumber to make sure that the string can be parsed to a number: Code: Dim i As Int If IsNumber(EditText1.Text) Then i = EditText1.Text Else ... Upvote 0
Strings are converted automatically: Code: Dim i As Int = EditText1.Text You can use IsNumber to make sure that the string can be parsed to a number: Code: Dim i As Int If IsNumber(EditText1.Text) Then i = EditText1.Text Else ...
O ovt001 Member Licensed User Longtime User Dec 18, 2012 #3 Dear Erel. If I use: Socket1.Connect("10.100.100.103",123,5000) it work's but if I use Socket1.Connect(strServer,intPort,5000) It doesn't works, but strServer contains "10.100.100.103" and intport contains 123 See code down Sub btnConnect_Click Dim intPort As Int = txtPort.Text Dim strServer As String strServer = txtServerIp Socket1.Initialize("Socket1") Socket1.Connect(strServer,intPort,5000) 'Socket1.Connect("10.100.100.103",123,5000) end sub Upvote 0
Dear Erel. If I use: Socket1.Connect("10.100.100.103",123,5000) it work's but if I use Socket1.Connect(strServer,intPort,5000) It doesn't works, but strServer contains "10.100.100.103" and intport contains 123 See code down Sub btnConnect_Click Dim intPort As Int = txtPort.Text Dim strServer As String strServer = txtServerIp Socket1.Initialize("Socket1") Socket1.Connect(strServer,intPort,5000) 'Socket1.Connect("10.100.100.103",123,5000) end sub
Erel B4X founder Staff member Licensed User Longtime User Dec 18, 2012 #4 Please use [ code ] [ /code ] tags (without spaces) when posting code. Check the values of intPort and strServer with the debugger. Make sure that there are no extra spaces. Upvote 0
Please use [ code ] [ /code ] tags (without spaces) when posting code. Check the values of intPort and strServer with the debugger. Make sure that there are no extra spaces.
mc73 Well-Known Member Licensed User Longtime User Dec 18, 2012 #5 By the way, a notice I have and hopefully I don't have to change thread. While quering an sqlite db, noticed that when requesting an int field, and the filed is null, I get a 0. Don't know if this is how it goes, but surely it would be nice for me to throw an error (so I can do other things with the null result). For now, my workaround is to request a string and check if it is 'null'. Upvote 0
By the way, a notice I have and hopefully I don't have to change thread. While quering an sqlite db, noticed that when requesting an int field, and the filed is null, I get a 0. Don't know if this is how it goes, but surely it would be nice for me to throw an error (so I can do other things with the null result). For now, my workaround is to request a string and check if it is 'null'.
M Mahares Expert Licensed User Longtime User Dec 18, 2012 #6 @mc73: In order to avoid unwanted 0 in a SQLite table insert, update or query, I have started storing field type (data type) as TEXT even for numbers instead of INTEGER or REAL, except of course for a PRIMARY KEY. By doing so, you can still validate numbers before inserts and updates and you can insert an empty string without a 0 popping up when you query the data. Your friend Mahares Upvote 0
@mc73: In order to avoid unwanted 0 in a SQLite table insert, update or query, I have started storing field type (data type) as TEXT even for numbers instead of INTEGER or REAL, except of course for a PRIMARY KEY. By doing so, you can still validate numbers before inserts and updates and you can insert an empty string without a 0 popping up when you query the data. Your friend Mahares
O ovt001 Member Licensed User Longtime User Dec 18, 2012 #7 Dear all, I found the problem.. very stupid I am :signOops: :sign0013: Code: 1. Sub btnConnect_Click 2. Dim intPort As Int = txtPort.Text 3. Dim strServer As String 4. strServer = txtServerIp 5. Socket1.Initialize("Socket1") 6. Socket1.Connect(strServer,intPort,5000) 7. 'Socket1.Connect("10.100.100.103",123,5000) 8. end sub but the line 4. must be: 4. strServer = txtServerIp.text Sorry, And thank you for yours helps O. Upvote 0
Dear all, I found the problem.. very stupid I am :signOops: :sign0013: Code: 1. Sub btnConnect_Click 2. Dim intPort As Int = txtPort.Text 3. Dim strServer As String 4. strServer = txtServerIp 5. Socket1.Initialize("Socket1") 6. Socket1.Connect(strServer,intPort,5000) 7. 'Socket1.Connect("10.100.100.103",123,5000) 8. end sub but the line 4. must be: 4. strServer = txtServerIp.text Sorry, And thank you for yours helps O.