|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Holding a referenceI'm having trouble with references. Specificly i want to maintain a
reference to a string. So that after I pass it to the constructor, other methods can have at it. I can do this is C/C++, but I can't seem to make it work in VB. In the constructor I have Me.Value = value ' where value was pass ByRef, and ' Me.Value was declared global As String. when i return to where the func was called, the string put in is not there. *** Sent via Developersdex http://www.developersdex.com *** It doesn't look like you are trying to change the value of the external
string. All it seems you are doing is setting the initial value of the Value property of the class instance that your code is wrapped inside of. When you return to your function, your original string should still be there, as nothing has attempted to change it. Please show us the code that is calling the code below and show the whole constructor code as well. Show quoteHide quote "Dagoberto Aceves" <dace***@devdex.com> wrote in message news:ujJ1dMAOGHA.3556@TK2MSFTNGP10.phx.gbl... > I'm having trouble with references. Specificly i want to maintain a > reference to a string. So that after I pass it to the constructor, other > methods can have at it. I can do this is C/C++, but I can't seem to make > it work in VB. > In the constructor I have > > Me.Value = value ' where value was pass ByRef, and > ' Me.Value was declared global As String. > > when i return to where the func was called, the string put in is not > there. > > > > *** Sent via Developersdex http://www.developersdex.com *** The function calling the new form goes like this.
... Dim getResult As String f = New SingleItemListEdit(type, True, getResult) ... ' In constructor Public Sub New(ByVal thisList As List_Editor, ByVal setDialog As Boolean, ByRef value As String) ... Me.value = value ' A way to communicate back to the calling form ' In global Public value As String ' Other function use the Me.value *** Sent via Developersdex http://www.developersdex.com *** Dagoberto,
You are passing a pointer to a pointer which points to Nothing, what is the sense of that. Cor |
|||||||||||||||||||||||