Joined: 22 Jul 2009
Location: United States
Online Status: Offline
Posts: 2
Topic: Custom Function - "Is_NonAlpha" Posted: 22 Jul 2009 at 3:02pm
The lastname field in our DB is varchar and the software has no constraints. So although it is supposed to be alpha only (no symbols, no numbers), it isn't.
I am attempting to write a custom function in Crystal that will look at the string passed in and return true if the field is not purely alphabetical. I've tried this several ways and I must keep doing something wrong.
At this point, my function always returns false.
My function is below - any ideas? Thanks!
Function Is_NonAlpha(inString AS String) as Boolean
Dim n as Number
n = 1
Dim toReturn as Boolean
toReturn = false
For n = 1 to Len(inString)
if Not((Mid(inString, n, 1) Like "[A-Za-z( )]")) then
toReturn = true
end if
Next
Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Posted: 23 Jul 2009 at 10:03am
Yeah, that works...I'm not sure what I would have done, it was an off the top of my head....yeah, I agree hard coding is bad...you might miss something.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum