Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4android > Basic4android Updates and Questions
Documentation Wiki Register Members List Windows Mobile Search Today's Posts Mark Forums Read

Basic4android Updates and Questions Updates and questions regarding Basic4android.

String to Int ???

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-19-2011, 03:27 PM
Junior Member
 
Join Date: Jan 2011
Posts: 82
Default String to Int ???

Do you Know how to do that :

Code:
if MyTextBox.text > 0  then
...
end if
( MyTextBox.text = "1234")

i've got this error : " NumberFormatException"

It is not possible to do somthing like cint(MyTextBox.text) in order to get me a Integer of my text value ?
Reply With Quote
  #2 (permalink)  
Old 05-19-2011, 03:55 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 25,889
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

Your code should work, assuming that the string is indeed a number. Make sure that there are no extra spaces in the string.

You can use IsNumber to check if the string can be parsed as a number.
Reply With Quote
  #3 (permalink)  
Old 05-19-2011, 04:00 PM
Junior Member
 
Join Date: Jan 2011
Posts: 82
Default

ok...thanks
Reply With Quote
  #4 (permalink)  
Old 05-19-2011, 04:28 PM
Junior Member
 
Join Date: Mar 2011
Posts: 57
Default

to "bypass" a null string, I always use

"0" & MyTextBox.text > 0

so it the textbox is empty, this gives

"0" & "" = 0

if it is "1234" -> "01234" > 0

it works
Reply With Quote
  #5 (permalink)  
Old 05-20-2011, 06:02 PM
Junior Member
 
Join Date: May 2011
Posts: 69
Default

Quote:
Originally Posted by vangogh View Post
to "bypass" a null string, I always use

"0" & MyTextBox.text > 0

so it the textbox is empty, this gives

"0" & "" = 0

if it is "1234" -> "01234" > 0

it works
Can someone explain more a bit? I've the same problem..
Reply With Quote
  #6 (permalink)  
Old 05-21-2011, 11:26 PM
Junior Member
 
Join Date: Mar 2011
Posts: 57
Default

simply use the debugger and try my suggestion step by step... it works

my post isn't a problem but a workaround
Reply With Quote
  #7 (permalink)  
Old 05-22-2011, 08:23 PM
Basic4android Expert
 
Join Date: May 2011
Posts: 752
Default

Quote:
Originally Posted by fabero View Post
Can someone explain more a bit? I've the same problem..
Let's say the user enters nothing in the text box

Since you're checking 0 & textbox.text, it will read "0" which is a number, instead of crashing.

You can also just use IsNumber () to check if it's valid first

Last edited by NeoTechni : 05-22-2011 at 08:25 PM.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
put string in map Cor Basic4android Updates and Questions 3 04-29-2011 07:14 AM
TextChanged (Old As String, New As String) cnicolapc Basic4android Updates and Questions 2 03-17-2011 05:51 AM
wish: Val(string) nfordbscndrd Bugs & wishlist 4 02-05-2011 02:28 AM
How split string in a string with numbers? sitajony Questions (Windows Mobile) 4 04-26-2010 06:43 PM
string ? derez Beta Versions 4 03-03-2010 08:06 PM


All times are GMT. The time now is 02:40 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0