UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
2 Pages V < 1 2  (Go to first unread post)
   Reply to this topicStart new topic
> How Do I Populate Array Using A String Data, Access 2016    
 
   
ADezii
post Apr 9 2020, 11:55 AM
Post#21



Posts: 2,990
Joined: 4-February 07
From: USA, Florida, Delray Beach


QUOTE
So, was that the result you were expecting?

I didn't expect the LBound(arrValues) and the UBound(arrValues) to equate to 0. Given that statement, I did expect the Output from your Code Revision to be exactly what it was.
Go to the top of the page
 
theDBguy
post Apr 9 2020, 12:05 PM
Post#22


UA Moderator
Posts: 78,098
Joined: 19-June 07
From: SunnySandyEggo


QUOTE (ADezii)
I didn't expect the LBound(arrValues) and the UBound(arrValues) to equate to 0. Given that statement, I did expect the Output from your Code Revision to be exactly what it was.

Hi. Not sure we're on the same page. If you select 30, 67, 31, and 99 in your Listbox, your old function returns the following:

30;67;31;99

If you use my new function, it would return the following:

varValue(0): 30;67;31;99

However, I would expect the following as the "proper" result if using the new function:

varValue(0): 30
varValue(1): 67
varValue(2): 31
varValue(3): 99

Do you agree?

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
ADezii
post Apr 9 2020, 12:31 PM
Post#23



Posts: 2,990
Joined: 4-February 07
From: USA, Florida, Delray Beach


  1. It is probably my misunderstanding theDBguy, but there is only a single Index (0) into the Array: varValues(1), varValues(2), and varValues(3) do not exist. Any other Index other than 0 will generate a Runtime Error, as in:
    CODE
    Public Sub DemoParamArray_3(ParamArray varValues() As Variant)
    On Error GoTo Err_DemoParamArray_3

    10 Debug.Print varValues(0)     '30;67;31;99
    20 Debug.Print varValues(1)     'Will Error on this Line
      
    Exit_DemoParamArray_3:
      Exit Sub
      
    Err_DemoParamArray_3:
      Debug.Print Err.Description
        Resume Exit_DemoParamArray_3
    End Sub
  2. OUTPUT:
    CODE
    30;67;31;99
    Subscript out of range

This post has been edited by ADezii: Apr 9 2020, 12:32 PM
Go to the top of the page
 
theDBguy
post Apr 9 2020, 12:39 PM
Post#24


UA Moderator
Posts: 78,098
Joined: 19-June 07
From: SunnySandyEggo


Ahh, I guess you're not seeing what David was trying to say earlier. If you use a ParamArray, it is supposed to be able to accept multiple arguments. In the way you're passing the arguments as a [concatenated] String, you're only really passing one argument to it, instead of many.

To demonstrate, if you have the following function:
CODE
Public Sub TestIt(ParamArray var() As Variant)

Debug.Print UBound(var)

End Sub

Then you should get the following result (in the Immediate Window):
CODE
TestIt 1
0
TestIt 1,2,3
2
TestIt "1,2,3"
0

Does that make sense? Now, if it's me who is missing something, please let me know. Thanks.

PS. By the way, did you notice in the sample code you just posted above, you didn't have to use the Join() function? I think that's what was confusing the result earlier. I think you were thinking the array varValues() had multiple items in it, so you try to "join" them; when in reality, there was only one element, but the content of that one element and the result of a Join() looked the same, so the problem wasn't so obvious.

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
ADezii
post Apr 9 2020, 12:53 PM
Post#25



Posts: 2,990
Joined: 4-February 07
From: USA, Florida, Delray Beach


@theDBguy:
I do believe that the misunderstanding was 100% on my end, but all is crystal clear now. My apologies to you and David.
Go to the top of the page
 
theDBguy
post Apr 9 2020, 01:00 PM
Post#26


UA Moderator
Posts: 78,098
Joined: 19-June 07
From: SunnySandyEggo


QUOTE (ADezii)
@theDBguy:
I do believe that the misunderstanding was 100% on my end, but all is crystal clear now. My apologies to you and David.

Hi. Glad to hear we're all on the same page now. Okay, still, it would be nice to figure out a way to "concatenate" a String and pass it to the ParamArray argument, somehow, that it would be recognized as multiple arguments, instead of just one. Cheers!

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
2 Pages V < 1 2


Custom Search


RSSSearch   Top   Lo-Fi    26th May 2020 - 06:28 PM