Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

String Parse Question

Posted on 2006-11-29
6
Medium Priority
?
197 Views
Last Modified: 2010-05-03
Hello all.  I have a file name such as this:

DSDAD FR6503 111806.txt

I need to grab the date in this the 111906.  What string parse can I use?  thanks all
0
Comment
Question by:sbornstein2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 29

Accepted Solution

by:
Nightman earned 500 total points
ID: 18038873
If the length and format is consistent:

strTemp = "DSDAD FR6503 111806.txt"
MsgBox (DateSerial("20" & Mid(strTemp, 18, 2), Mid(strTemp, 14, 2), Mid(strTemp, 16, 2)))
0
 

Author Comment

by:sbornstein2
ID: 18038935
Is there a way I can first grab the text of 111806 and then check if it is a date?  I think this would be easiest and then just set that to a date variable I have.
0
 

Author Comment

by:sbornstein2
ID: 18039083
also the file name could be different I need to work from left to right to grab it I think.  The date will always be MMDDYY.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 29

Expert Comment

by:Nightman
ID: 18039532
You could parse it out and use the IsDate(expression) - returns a boolean - if you want.
What do you mean about the file name being different? What other permutations are there?
0
 

Author Comment

by:sbornstein2
ID: 18039763
well your using a mid and the beginning of that file name prior to the date can possibly be different.  I think I am going to do this which is safer.

 strFileDate = Trim(Mid(myFile, InStr(myFile, ".txt") - 6, 6))
    If Len(strFileDate) = 6 Then
        strFileDate = Left(strFileDate, 2) & "/" & Mid(strFileDate, 3, 2) & _
            "/" & Format(Right(strFileDate, 1), "00")
    End If
   
    'Get File Date - if invalid write to error log and skip file
    If IsDate(strFileDate) = False Then
    End If
0
 
LVL 29

Expert Comment

by:Nightman
ID: 18039857
Your's is safer, true, but that's why I asked about the format. A fixed format makes for easier (and more efficient) code. And means that a simple answer would also do ;)

Cheers
Night
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question