Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Grabbing a substring?

Status
Not open for further replies.

DustoBOE

Technical User
Dec 12, 2013
25
US
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:
    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)
 
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,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
The January 1, 2014 is the "As of" date. The end date of the report is the 123113.
 
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
 
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?
 
Code:
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
 
did you see my code answer?

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
I forget that this VB language is terribly inadequate.

Just Dim MyDate

with no variable type

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top