UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> How to count the number of times "/" appears in string    
 
   
fiftyfour
post Jan 24 2008, 01:06 PM
Post #1

UtterAccess Guru
Posts: 774
From: Illinois



I have a text box for dates. I don't care if the date is in the "mm/dd/yyyy" format, or the "m/d/yy" format.

I do not want to use the Short Date Input Mask Property for the text box...takes too long for data entry.

I thought that I would use the BeforeUpdate event to capture the string that was entered by the user.

What I would like to do is to count the number of times that the date separator "/" is found in that string. If that character shows up twice in that string, then I have a good date. If the character only shows up once, then the user entered "m/yyyy" or some other variation.

What would be the code that I could use to return the number of times that a specific character is used in a string?

Thanks for your help.
Go to the top of the page
 
+
freakazeud
post Jan 24 2008, 01:09 PM
Post #2

UtterAccess VIP
Posts: 31,413
From: NC, USA



Hi,
why not use a calendar control to pick the date. Probably pretty fast and there will be no ambiguity. There are so many different ways the user could screw up which your code would probably not cover.
HTH
Good luck
Go to the top of the page
 
+
fiftyfour
post Jan 24 2008, 02:56 PM
Post #3

UtterAccess Guru
Posts: 774
From: Illinois



Thank you for the idea...but I'm also going to limit the date to no further back than 16 days.

CODE


If Date - CDate(Me.MyDate) > 16 Then

     MsgBox "The date you entered is older than....blah blah blah"

     GoTo ExitThisSub

End IF


Could also use the DateDiff function

But, I don't know how to make a calendar control limit the time period to only 16 days.

Thanks,
Go to the top of the page
 
+
freakazeud
post Jan 24 2008, 03:58 PM
Post #4

UtterAccess VIP
Posts: 31,413
From: NC, USA



Evaluate the selection the user makes...and give feedback based on that. The user could still enter a value outside of the 1 days, too so why not let them select it.
HTH
Good luck
Go to the top of the page
 
+
Bob_L
post Jan 24 2008, 04:07 PM
Post #5

Utterly Banned
Posts: 7,038



Just strange how typing 050408 with an input mask is harder than typing 5/4/08 (same number of characters.

use an input mask of

09/09/0099;;_

and it makes it really quick as you don't need the optional (9) digits.
Go to the top of the page
 
+
fiftyfour
post Jan 24 2008, 06:11 PM
Post #6

UtterAccess Guru
Posts: 774
From: Illinois



I went with the input mask...and I really appreciate help from both. Thank you so much.
Go to the top of the page
 
+

Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Go to Top  ·  Lo-Fi Version Time is now: 20th June 2013 - 07:31 AM