×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Grabbing a substring?

Grabbing a substring?

Grabbing a substring?

(OP)
I know, i've looked around a bit and I'm not sure how to grab a substing. Maybe there's an easier way to do what i want. I probably could use a little guidance. I made the combobox, but I wasnt sure the best way to translate their selection to the 6 digit date, ie. "January 1, 2014 123112"...i would want to store the 6 digit date into a string for placement on the session screen.

If there's a easier way to assign the variable the six digit date? The 6 digit date does not need to be in the combobox, i.e. when they select "January 1, 2014", a variable would automatically be populated with "123112". That would look cleaner.

I don't know enough to know where to go here.

Thanks in advance.


CODE --> VB

Dim cboReportDate (12) as string
    cboReportDate(0) =  "January 1, 2014   123112"
    cboReportDate(1) =  "February 1, 2014  013113"
    cboReportDate(2) =  "March 1, 2014     022813"
    cboReportDate(3) =  "April 1, 2014     033113"
    cboReportDate(4) =  "May 1, 2014       043013"
    cboReportDate(5) =  "June 1, 2014      053113"
    cboReportDate(6) =  "July 1, 2014      063013"
    cboReportDate(7) =  "August 1, 2014    073113"
    cboReportDate(8) =  "September 1, 2014 083113"
    cboReportDate(9) =  "October 1, 2014   093013"
    cboReportDate(10) = "November 1, 2014  103113"
    cboReportDate(11) = "December 1, 2014  113013"

dim yourselection as string
    
    Begin Dialog dlgOptions 10, 28, 140, 140, "      ---Assignee---"
    
    OkButton      80, 17, 45, 20,.btnOK
    DropComboBox  10, 20, 60, 20, cboReportDate(), .cboReportDate
    cancelbutton  80, 45, 45, 20, .btnCancel 
    End Dialog
    iDone = FALSE

   
    While (iDone = FALSE) 'This is what this does
        Dim dlgVar as dlgOptions
        nRet = Dialog(dlgVar)
        Select Case nRet
            Case -1     ' -1 is returned if the user chose OK
                'msgbox nRet
                iDone = TRUE 
                
            Case 0      ' 0 is returned if the user chose Cancel 
                'msgbox nRet
                Exit sub    
                
        End Select
    Wend
    YourSelection = dlgvar.cboreportdate
 'dim yourselection as strDate
    
   ' msgbox yourselection(18, 6) 

RE: Grabbing a substring?

hi,

???

Please explain how 123112 translates to jan 1 2014???

It would seem logical to me that the structure of thoese string is probably mmddyy. Using that logic, each of your strings look like they refer to month end dates, so with the exception of the first, which I'd guess should be 123113, and your dates are the first of the next month.

CODE

dim MyDate as Date, YourString

MyDate = DateSerial(CInt(Mid(yourselection,5,1))+2000, CInt(Mid(yourselection,1,1))+1, 1) 

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

RE: Grabbing a substring?

(OP)
The January 1, 2014 is the "As of" date. The end date of the report is the 123113.

RE: Grabbing a substring?

(OP)
so if i run the report on Jan 1, 2014, i want the begin date of 010100 (jan 1 2000) which is hard coded and the end date for jan 1 would be 123113. And so on for each month.

I also have many reports that will use different date ranges (not always 010100 as start date), so maybe going from the combobox selection to a set of ranges is better and reassigning "yourselection"

RE: Grabbing a substring?

(OP)
Report Date 12 month or More 6 month 5 month 4 to 5 month 10 day / 235 A
January 1, 2014 1/1/00 to 12/31/12 01/01/13 to 6/30/13 07/01/13 to 07/31/13 7/01/13 to 8/31/13 1/1/00 to 12/31/13
February 1, 2014 1/1/00 to 1/31/13 02/01/13 to 07/31/13 08/01/13 to 08/31/13 8/1/13 to 9/30/13 1/1/00 to 1/31/14
March 1, 2014 1/1/00 to 2/28/13 03/01/13 to 8/31/13 09/01/13 to 09/30/13 9/1/13 to 10/31/13 1/1/00 to 2/28/14
April 1, 2014 1/1/00 to 3/31/13 04/01/13 to 09/30/13 10/01/13 to 10/31/13 10/1/13 to 11/30/13 1/1/00 to 3/31/14
May 1, 2014 1/1/00 to 4/30/13 05/01/13 to 10/31/13 11/01/13 to 11/30/13 11/1/12 to 12/31/13 1/1/00 to 4/30/14
June 1, 2014 1/1/00 to 5/31/13 06/01/13 to 11/30/13 12/1/13 to 12/31/13 12/1/13 to 1/31/14 1/1/00 to 5/31/14
July 1, 2014 1/1/00 to 6/30/13 07/01/13 to 12/31/13 01/01/14 to 1/13/14 1/1/14 to 2/28/14 1/1/00 to 6/30/14
August 1, 2014 1/1/00 to 7/31/13 08/01/13 to 01/31/14 2/1/14 to 2/28/14 2/1/14 to 3/31/14 1/1/00 to 7/31/14
September 1, 2014 1/1/00 to 8/31/13 09/01/13 to 02/28/14 3/1/14 to 3/31/14 3/1/14 to 4/30/14 1/1/00 to 8/30/14
October 1, 2014 1/1/00 to 9/30/13 10/01/13 to 03/31/14 4/1/14 to 4/30/14 4/1/14 to 5/31/14 1/1/00 to 9/30/14
November 1, 2014 1/1/00 to 10/31/13 11/30/13 to 04/30/14 5/1/14 to 5/31/14 5/1/14 to 6/30/14 1/1/00 to 10/31/14
December 1, 2014 1/1/00 to 11/30/13 12/31/13 to 05/31/14 6/1/14 to 6/30/14 6/1/13 to 7/31/14 1/1/00 to 11/30/14



These are my ranges I'm working with. And what I'm doing is trying to make it all automated. Does that help explain?

RE: Grabbing a substring?

(OP)

CODE --> aa

Report Date	 12 month or More 	6 month	                5 month	                  4 to 5 month	        10 day / 235 A
January 1, 2014	 1/1/00 to 12/31/12	01/01/13 to 6/30/13	07/01/13 to 07/31/13	7/01/13 to 8/31/13	1/1/00 to 12/31/13
February 1, 2014   1/1/00 to 1/31/13	02/01/13 to 07/31/13	08/01/13 to 08/31/13	8/1/13 to 9/30/13 	1/1/00 to 1/31/14
March 1, 2014	 1/1/00 to 2/28/13	03/01/13 to 8/31/13	09/01/13 to 09/30/13	9/1/13 to 10/31/13	1/1/00 to 2/28/14
April 1, 2014	 1/1/00 to 3/31/13	04/01/13 to 09/30/13	10/01/13 to 10/31/13	10/1/13 to 11/30/13	1/1/00 to 3/31/14
May 1, 2014	 1/1/00 to 4/30/13	05/01/13 to 10/31/13	11/01/13 to 11/30/13	11/1/12 to 12/31/13	1/1/00 to 4/30/14
June 1, 2014	 1/1/00 to 5/31/13	06/01/13 to 11/30/13	12/1/13 to 12/31/13	12/1/13 to 1/31/14	1/1/00 to 5/31/14
July 1, 2014	 1/1/00 to 6/30/13	07/01/13 to 12/31/13	01/01/14 to 1/13/14	1/1/14 to 2/28/14 	1/1/00 to 6/30/14
August 1, 2014	 1/1/00 to 7/31/13	08/01/13 to 01/31/14	2/1/14 to 2/28/14 	2/1/14 to 3/31/14 	1/1/00 to 7/31/14
September 1, 2014  1/1/00 to 8/31/13	09/01/13 to 02/28/14	3/1/14 to 3/31/14 	3/1/14 to 4/30/14 	1/1/00 to 8/30/14
October 1, 2014	 1/1/00 to 9/30/13	10/01/13 to 03/31/14	4/1/14 to 4/30/14 	4/1/14 to 5/31/14 	1/1/00 to 9/30/14
November 1, 2014  1/1/00 to 10/31/13	11/30/13 to 04/30/14	5/1/14 to 5/31/14 	5/1/14 to 6/30/14 	1/1/00 to 10/31/14
December 1, 2014  1/1/00 to 11/30/13	12/31/13 to 05/31/14	6/1/14 to 6/30/14 	6/1/13 to 7/31/14 	1/1/00 to 11/30/14 

RE: Grabbing a substring?

did you see my code answer?

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

RE: Grabbing a substring?

(OP)
dim MyDate as Date, throws an error.

RE: Grabbing a substring?

I forget that this VB language is terribly inadequate.

Just Dim MyDate

with no variable type

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close