string to interger comparison?

dareuhl
Unregistered
 
Post: #1
how do i compare what i have inputted in a text box to an interger?

my main goal is to compare the number of inputted characters to an amount i want.
Quote this message in a reply
Moderator
Posts: 623
Joined: 2007.09
Post: #2
I assume you are not using Cocoa?

- Lincoln Green
http://www.binkworks.com/
Quote this message in a reply
Moderator
Posts: 1,560
Joined: 2003.10
Post: #3
What language, API, etc. are you using?
Quote this message in a reply
Moderator
Posts: 613
Joined: 2004.09
Post: #4
if Cocoa:
if([[textbox objectValue] intValue] == int)

If you want to compare the amount of characters entered though you will need to get the length of the string in the textbox with [[textbox ObjectValue] length]
Quote this message in a reply
Moderator
Posts: 623
Joined: 2007.09
Post: #5
if([[textbox stringValue] length] == int)

If you use kodex's code, you will need to make sure that you make the "O" in ObjectValue lowercase: [[textbox objectValue] length]

Hope this helps

BTW kodex: What is the difference between objectValue and stringValue? Is there an advantage to using objectValue?

- Lincoln Green
http://www.binkworks.com/
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #6
[[textBox stringValue] length] is utterly irrelevant...
Quote this message in a reply
Member
Posts: 283
Joined: 2006.05
Post: #7
OSC - Why? Did you see the second line of the OP?
Quote this message in a reply
Moderator
Posts: 613
Joined: 2004.09
Post: #8
Hairball183 Wrote:If you use kodex's code, you will need to make sure that you make the "O" in ObjectValue lowercase: [[textbox objectValue] length]

Hope this helps

BTW kodex: What is the difference between objectValue and stringValue? Is there an advantage to using objectValue?

Sorry about the Caps error was just typing a quick reply in safari and didn't notice.

As far as using objectValue over stringValue, there was an issue I had in one of my programs a long time ago (that I can't recall) that wasn't functioning correctly with stringValue so I just got into the habit of using objectValue instead, as far as I know objectValue just uses stringValue if a string value is present.

OSC: I wasn't sure if he was asking about the length of a string because he said his goal was to compare the number of inputed characters which would make his first question irrelevant, I figured I would supply both answers to prevent the classic "No I meant this...." reply.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #9
Whoops, serves me right for not reading closely enough Smile
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  formatting value in a string sefiroths 3 3,863 Dec 12, 2011 02:41 AM
Last Post: sefiroths
  Getting a value from a String Megamac04 5 3,648 Jan 31, 2010 04:23 PM
Last Post: smasher
  Parsing from a string to something faster? Madrayken 3 2,999 Aug 10, 2009 03:32 PM
Last Post: smasher
  Is -fconstant-string-class broken under the XCode/Next runtime Justin Brimm 17 7,372 Jun 12, 2008 01:04 PM
Last Post: Justin Brimm
  char array versus pointer to string constant question WhatMeWorry 7 7,200 Jan 30, 2007 12:26 PM
Last Post: bronxbomber92