View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
DAV135 DAV135 is offline
external usenet poster
 
Posts: 11
Default formatting input boxes

Split the checking into 4 section to be certain...

'Check the number of characters....
if len(sYear) < 6 then
'Error Message
end if

you also need to validate each section (ie the year and the quarter),
to do this is also simple...

'Check that the first 4 characters are numbers which will represent the
year.
if isnumeric(left(sYear,4)) = false then
'Error Message
end if

'Check that the 5th character is the letter "Q".
if mid(sYear,5,1)) < "Q" then
'Error Message
end if

'Check that the final character is a number which represents the
quarter.
if isnumeric(right(sYear,1)) = false then
'Error Message
end if

Obviously you can just put them all into one if statement using the OR
command, but thought it would be easier to explain that way.