Results 1 to 8 of 8
  1. #1
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919

    Adherence to the Option Base 1 setting?

    Any way to force the Split function to adhere to the Option Base 1 setting? Works okay for static declarations but ignored with dynamic allocations. Maybe a hidden option in the parameter list to Split I missed?
    Click image for larger version. 

Name:	000.jpg 
Views:	19 
Size:	13.0 KB 
ID:	49284
    Code:
    Option Compare Database
    Option Explicit
    Option Base 1            <<<<<<<<<<<<<<
    
    
    Const str As String = "Marge, Mary, Joan, Jason, Michael & Peter - Plus Henry, Philip, & Macy Head - & Joseph Arnold"
    Dim strChList As String
    Dim strTst As String
    Dim Ndx As Integer
    Dim MaxNdx As Integer
    Dim ChAr() As String          <<<<<<<<<<<<<<
    Dim LnAr(10) As String       <<<<<<<<<<<<<<
    Dim lngMaxLn As Long
    Dim Lndx As Integer
    Dim ISayStop As Boolean
    Dim DoLine As Boolean
    Dim I As Integer
    Private Sub tst()
    lngMaxLn = 2160       '1.5 inches
    lngMaxLn = 2880       '2.0 inches
    lngMaxLn = 2760       'TMS profiles
    strChList = "Marge, Mary, Joan, Carol, Jason, Michael & Peter - Plus Henry, Bill, Lori, Philip, & Macy Head - Plus Joseph & Kathy  Arnold"
    Lndx = -1
    strTst = ""
    Ndx = 0
    ChAr = Split(strChList, " ")
    MsgBox "lbound(ChAr) = " & LBound(ChAr) & "  lbound(LnAr) = " & LBound(LnAr)


  2. #2
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    A lot simpler to Dim the array to start at one?
    ChAr(1 To 10) As String

    You're liable to confuse anyone by using Base 1 - including yourself later on.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    Yes, the use of Base 1 can cause more confusion than one desires. I don't think I've used it in well over 10 or 12 years, and even then is was a strange situation to begin with. The issue with the OP is that "Split" doesn't adhere to the module's Base setting, thereby creating a major inconsistency nobody wants to deal with. I'll leave the OP unsolved for now and return to Base 0 as I've always done.

    Four inches of new snow in Reno this morning that we don't need, maybe we can ship it up to you up there if you run short

  4. #4
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    Bring it on! I have an Outback that I personally know will plow through 17" of new snow as if it were nothing.
    Split returns a zero based array, or so says the documentation so I'd say you're stuck with it.

    You declare a const and a string for the same thing? By splitting at space you want list values like
    Michael
    Peter
    &
    -
    Plus
    Henry
    and so on?
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    That's just a test string you can ignore. I just wanted sample code that demonstrated the lack of consistency with the BASE between static and dynamic dimensions.

    Ah yes, when we still lived in Graeagle, plowing 18" of new snow off the driveway was always fun. Reno by comparison is "child's play"

  6. #6
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    lack of consistency with the BASE between static and dynamic dimensions
    Say whaaat?
    If a tool makes one thing and you use that tool, don't expect it to make something else.
    I suppose you could first make a post, then a toothpick:

    Code:
    ChAr = Split("Marge, Mary, Joan, Carol, Jason, Michael & Peter - Plus Henry, Bill, Lori, Philip, & Macy Head - Plus Joseph & Kathy  Arnold", ",")
    For I = 1 To UBound(ChAr)
         ReDim Preserve ary(I)
         ary(I) = ChAr(I - 1)
    Next
    
    Lndx = -1
    strTst = ""
    Ndx = 0
    
    MsgBox LBound(ary)
    MsgBox "lbound(ChAr) = " & LBound(ChAr) & "  lbound(LnAr) = " & LBound(LnAr)
    So ChAr becomes ary, which is one based.

    You realize that ChAr is Char, a reserved word?
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  7. #7
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    I'd start laughing, but with the headaches I've experienced with the changes to this historic app, it's not funny. "ChAr" as typed with capitals obscured that I was messing with what I already know is the reserved word "Char". I believe the original intent was to be short for "Child Array". Conventionally, it should have been "strChAr" to begin with. I think I'd better do a thorough audit of this old app to see where else there might be a snake hiding in the grass.

    Thanks for the wakeup call..............

  8. #8
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    Except for the obvious and oft used things like sql, i, x, n, etc. I usually 'type' my variables, so yeah, strChar for sure.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 8
    Last Post: 06-12-2018, 03:05 PM
  2. Replies: 9
    Last Post: 10-07-2014, 06:53 PM
  3. Replies: 4
    Last Post: 09-18-2014, 06:41 AM
  4. Replies: 1
    Last Post: 07-08-2014, 06:22 AM
  5. setting up option boxes for text values
    By wlumpkin in forum Access
    Replies: 4
    Last Post: 02-08-2011, 09:33 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums