move a text field to an array - search one element at a time

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • JH001A
    New Member
    • Oct 2006
    • 16

    move a text field to an array - search one element at a time

    I need to search a text field for dates and move them to date fields. I am sure I have done this in the past using arrays but can't remember how I did it. here is a sample text fields.

    "perfect attendance 2nd qtr, remove 1 occurrence (08/09/05 & 1/2 of 10/14/05)"
    "Perfect Attendance 1st Qtr, remove 1 occurrence (09/12/05)"
    Thanks to anyone woh can help.

    JH001A.
  • PEB
    Recognized Expert Top Contributor
    • Aug 2006
    • 1418

    #2
    Yeah, you can save the obtained dates in an array...

    So your function can be like:
    Global mydates(20)

    Function save_date_in_ar ray(Stri) as integer
    dim i
    dim dd

    dd=0
    for i=1 to len(Stri)-8
    if isdate(mid(Stri ,i,8))= true then
    dd=dd+1
    mydates(dd)=CVD ate(mid(Stri,i, 8))
    end if
    next i
    save_date_in_ar ray=dd
    End function

    Best regards

    Comment

    • JH001A
      New Member
      • Oct 2006
      • 16

      #3
      Originally posted by PEB
      Yeah, you can save the obtained dates in an array...

      So your function can be like:
      Global mydates(20)

      Function save_date_in_ar ray(Stri) as integer
      dim i
      dim dd

      dd=0
      for i=1 to len(Stri)-8
      if isdate(mid(Stri ,i,8))= true then
      dd=dd+1
      mydates(dd)=CVD ate(mid(Stri,i, 8))
      end if
      next i
      save_date_in_ar ray=dd
      End function

      Best regards

      ^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^ ^
      Thanks for the reply.
      ^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^ ^

      Comment

      • Killer42
        Recognized Expert Expert
        • Oct 2006
        • 8429

        #4
        Originally posted by PEB
        dd=0
        for i=1 to len(Stri)-8
        if isdate(mid(Stri ,i,8))= true then
        dd=dd+1
        mydates(dd)=CVD ate(mid(Stri,i, 8))
        end if
        next i
        Just a minor point - you probably should adjust i after grabbing a date, just to avoid reprocessing the same text unnecessarily. At a guess, adding 8 to it would do the trick.

        Also, a question - is it possible the dates could be in different formats? Or to put it another way, are they manually entered, or generated by a program?

        Comment

        Working...