Normal Topic Is the first character a letter or a number? (Read 383 times)
NHUser
Full Member
***
Offline



Posts: 320
Location: Amherst, NH
Joined: Aug 2nd, 2010
Is the first character a letter or a number?
Nov 19th, 2015 at 9:13pm
Print Post Print Post  
I have an element (part number) that is populated with alpha and numeric characters.  I need to check On Form Entry if the part number element starts with a letter or a number.

I know I can isolate the first character, but other than checking against each letter in the alphabet, is there a way to check if that first character is a letter or a number?

Thanks!
  
Back to top
 
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: Is the first character a letter or a number?
Reply #1 - Nov 19th, 2015 at 9:32pm
Print Post Print Post  
You can use the SBasic function @Asc() to get the decimal value of the character and then use that to determine what it is.

Example:
Code
Select All
Var vChar as Char
Var vAscii as Int

	vChar = @Left(PartNumber, 1)
	vAscii = @Asc(vChar)
	If ((vAscii >= 48) and (vAscii <= 57)) Then
	{
		Writeln("It's a Number")
	}
	Else If ((vAscii >= 65) and (vAscii <= 90)) Then
	{
		Writeln("It's an Uppercase Letter")
	}
	Else If ((vAscii >= 97) and (vAscii <= 122)) Then
	{
		Writeln("It's a Lowercase Letter")
	} 



-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged