Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IS Function

Status
Not open for further replies.

lpb71

Technical User
Mar 10, 2004
57
GB
What is the IsNumeric equivalent to my command below to check that a character a-z has been entered.

if len(branchid)=3 and IsNumeric(branchid) then exit do

Thanks
 
[tt]if len(branchid)=1 and instr(1,branchid,"abcdefghijklmnopqrstuvwxyz",0)<>0 then exit do[/tt]
 
tsuji's code will not work for you. That looks for an occurrence of that entire string of 26 letters in your branchid variable.

Add this function to your code...
Code:
Public Function IsAlpha(ByVal sChr As String) As Boolean
    IsAlpha = sChr Like "[A-Za-z( )]"
End Function

It returns a boolean if your string contains alpha characters.

Code:
If IsAlpha(branchid) Then exit do
 
>tsuji's code will not work for you
That is not infrequent and that's truly fine as a comment.

But you cannot bend a language to your liking by pure imagination. This is vbs forum.
 
My error is inadvertently reversed the position of the 2 parameters. This is the correction.

[tt]if len(branchid)=1 and instr(1,"abcdefghijklmnopqrstuvwxyz",branchid,0)<>0 then exit do[/tt]
 
That would only work if the length of branchid is always going to be 1. The OP has a check for len(branchid) = 3.
 
Thanks Guys,

My OP will always be 1, could not get the Function to work, kept saying missing ")" on the public function line.

Used instr which works fine.

Thanks again Guys.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top