From: Ralph on 10 Oct 2009 21:23 "Eduardo" <mm(a)mm.com> wrote in message news:haqv0p$82a$1(a)aioe.org... > Ralph escribi�: > > > > You can write a function that returns a 'variable' ... > > > > Public Function GetStrFromPtr( ByRef addrVar As Long ) As String > > GetStrFromPtr = addrVar > > End Function > > It doesn't work for me: > (The long number is just converted to String) > > Option Explicit > > Dim A As String > Dim B As String > Dim C As String > > Dim mPointers(2) As Long > > Private Sub Form_Load() > A = "A" > B = "B" > C = "C" > mPointers(0) = StrPtr(A) > mPointers(1) = VarPtr(B) > mPointers(2) = StrPtr(C) > > End Sub > > Private Sub Command1_Click() > Dim iCr As Long > Dim iPt As Long > > For iCr = 0 To 2 > iPt = mPointers(iCr) > Debug.Print GetStrFromPtr(iPt) > Next iCr > End Sub > > Private Function GetStrFromPtr(ByRef addrVar As Long) As String > GetStrFromPtr = addrVar > End Function Yes, my reply was a little hasty. Hell a lot too hasty. You can do this from an outside dll. I had a reply I have created many moons ago, and used the above example as an example of psuedo-code for what the outside routine needed to look like. I opened the previous reply, did a quick scan, and posted without including the supporting details. Also notice that StrPtr() and ValPtr() do not report the same item when used on a VB String variable. sry -ralph
From: Ralph on 10 Oct 2009 21:23 "dpb" <none(a)non.net> wrote in message news:har6lg$gen$1(a)news.eternal-september.org... ha, as all of that went Swoooosh! right over my head it is obvious I haven't a clue what you are talking about, thus my comments are ignorable gibberish. -ralph
From: dpb on 11 Oct 2009 09:57 Ralph wrote: > "dpb" <none(a)non.net> wrote in message > news:har6lg$gen$1(a)news.eternal-september.org... > > ha, as all of that went Swoooosh! right over my head it is obvious I haven't > a clue what you are talking about, thus my comments are ignorable gibberish. .... OP's original stated objective in its essence... "I want to retain the references A,B and C, but I would like to assign values to A, B and C by indexing...such that by equating X(1) = "message 1", then A = "message 1"." That request is not achievable w/ a Variant (but trivial w/ Fortran EQUIVALENCE , for example). In fact, it isn't achievable at all in VB w/o resorting to serious tricks or non-native code or APIs. The facility is "needed" in a language if one is to be allowed such programming flexibility. It could be said to be "syntactic sugar" in such a trivial case but the same facility that allows this has many other uses that aren't at all trivial. One of the uses for C's union is named bit fields for interacting w/ hardware registers in a multiple-function register, for example. Writing code for that isn't as trivial in VB as it could be if could do so. That case can be worked around in VB; the previous really can't. That help???? :) --
From: Ralph on 11 Oct 2009 11:44 "dpb" <none(a)non.net> wrote in message news:hasog7$ugp$1(a)news.eternal-september.org... > Ralph wrote: > > "dpb" <none(a)non.net> wrote in message > > news:har6lg$gen$1(a)news.eternal-september.org... > > > > ha, as all of that went Swoooosh! right over my head it is obvious I haven't > > a clue what you are talking about, thus my comments are ignorable gibberish. > ... > > OP's original stated objective in its essence... > > "I want to retain the references A,B and C, but I would like > to assign values to A, B and C by indexing...such that by > equating X(1) = "message 1", then A = "message 1"." > > That request is not achievable w/ a Variant (but trivial w/ Fortran > EQUIVALENCE , for example). In fact, it isn't achievable at all in VB > w/o resorting to serious tricks or non-native code or APIs. > > The facility is "needed" in a language if one is to be allowed such > programming flexibility. It could be said to be "syntactic sugar" in > such a trivial case but the same facility that allows this has many > other uses that aren't at all trivial. > > One of the uses for C's union is named bit fields for interacting w/ > hardware registers in a multiple-function register, for example. > Writing code for that isn't as trivial in VB as it could be if could do > so. That case can be worked around in VB; the previous really can't. > > That help???? :) > yes
From: dpb on 11 Oct 2009 14:58
xytsrm wrote: > Actually the other language I was referring to was PLM86, a Pascal like > language that allowed indirect addessing through pointer references. .... The only way (other than the aforementioned implementation via a Fortran DLL or similar) I see to accomplish it in VB would be to make the variables GLOBALs and have a routine SET()/GET() like a class method that used the array to set/retrieve the global named variables. Not that I'd recommend do so... :) -- |