I am working on a string comparision issue where I need to bring out a numbers start with a particular char or number.
Here is an example.
I have 123
234
235
237
456
I need to bring out any number that start with 2. So the result should be 234,235,237.
Has anyone come across this scenario. Any suggestions would be appreciated.
Thanks.
String Comparison
Moderators: chulett, rschirm, roy
One way would be to simply substring the first character off and check to see if it is a '2'.
You could also do something similar in a Constraint:
Depends on what you mean by 'bring out'. You may need to add a 'trim' to that if there can be leading spaces involved.
Code: Select all
If YourField[1,1] = "2" Then DoSomething Else DoSomethingElse
Code: Select all
YourField[1,1] = "2"
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
-
- Participant
- Posts: 3593
- Joined: Thu Jan 23, 2003 5:25 pm
- Location: Australia, Melbourne
- Contact:
You can do your own experimentation on functions by writing a dummy routine and using the Test button to test various values. You will find this improves your knowledge of BASIC commands.
Create a routine, put into this routine the line:
Ans = left(234, 1), or
Ans = 234[1, 1] or
Ans = left(Arg1, 1)
Compile it and use the Test button to view the results. If your input field is numeric then you will be testing left(234, 1), if it's string you'll be testing left("234", 1). They both seem to give the same result. Looks like basic is very forgiving when it comes to sending a numeric field into a string function.
Create a routine, put into this routine the line:
Ans = left(234, 1), or
Ans = 234[1, 1] or
Ans = left(Arg1, 1)
Compile it and use the Test button to view the results. If your input field is numeric then you will be testing left(234, 1), if it's string you'll be testing left("234", 1). They both seem to give the same result. Looks like basic is very forgiving when it comes to sending a numeric field into a string function.
Certus Solutions
Blog: Tooling Around in the InfoSphere
Twitter: @vmcburney
LinkedIn:Vincent McBurney LinkedIn
Blog: Tooling Around in the InfoSphere
Twitter: @vmcburney
LinkedIn:Vincent McBurney LinkedIn
-
- Participant
- Posts: 75
- Joined: Tue May 13, 2003 4:14 am
- Location: California
- Contact: