Questions tagged [byref]

182 questions
2
votes
1 answer

Differences between address-of and ref operators

In my code I'm passing around some structures by reference, declaring them mutable and using the & symbol. The problem is that in some place the fields are corrupted (happens only in release mode) and I don't know absolutely why. I have found a fix,…
elmattic
  • 12,046
  • 5
  • 43
  • 79
2
votes
2 answers

F#: How to Call a function with Argument Byref Int

I have this code: let sumfunc(n: int byref) = let mutable s = 0 while n >= 1 do s <- n + (n-1) n <- n-1 printfn "%i" s sumfunc 6 I get the error: (8,10): error FS0001: This expression was expected to have type 'byref' but…
Nulle
  • 1,301
  • 13
  • 28
2
votes
2 answers

Fill an array with dates

Really can't see why the dates I'm pushing into an array are not the dates that come out when I call the array in the console. i.e. I would expect the first entry in the array to be today's date, which is what comes back from both alert calls, but…
Dan Solo
  • 697
  • 1
  • 8
  • 21
2
votes
2 answers

Working with arrays passed byref

I would like for someone to explain this to me: function myFunction(array){ array = $.grep(array, function(n,i){return n > 1 }); } var mainArray = [1,2,3]; myFunction(mainArray); document.write(mainArray) // 1,2,3, but i'm expecting 2,3 but…
Jason
  • 51,583
  • 38
  • 133
  • 185
2
votes
1 answer

VB.Net: Byref-in a parent type but return child type to ByRef

how do I keep the child type returned to the ByRef referenced variable in this scenario? Public Class Father End Class Public Class Son Inherits Father End Class ' Should return a Son, not a Father Public Sub Save(ByRef obj as Father)
Matthias Max
  • 595
  • 1
  • 7
  • 20
2
votes
2 answers

Get String Value of passed ByRef Variable

Say I call a function that uses a byref modifier. Once in the function, I want to fetch the string value of the passed variable. myvar := "george" passit(myvar) passit(byref whatvar){ msgbox % %whatvar% ;I should see a messagebox reporting…
bgmCoder
  • 6,205
  • 8
  • 58
  • 105
2
votes
1 answer

PHP: Is it possible to pass xml node to function by ref and make change?

I wish to pass a xml node to a function by ref, and make change within the function. But seem the node's value couldn't be changed in this way. Example: foo'; $xml =…
2
votes
3 answers

VB.NET - Function Cannot Modify a Member Of An Array

I'm trying to pass an Array to a Sub so the Sub can modify one of the values of the array. Something like this Dim a As String = "STARTVALUE" PopulateDataSet("Management", {a}) Public Sub PopulateDataSet(ByRef SomeRandomOtherVariable As String,…
TRH
  • 608
  • 1
  • 8
  • 24
2
votes
1 answer

vbval vs public variable

In VBA, I generally define shared variables as Public as opposed to building references via byVal or byRef. Most commonly, I call a subroutine or function to establish a value for said variable. Will someone please explain to me the benefit of…
2
votes
1 answer

Test at runtime if a passed in ByRef parameter shares storage location with a given "other" variable

This question is more out of curiosity than out of a practical need. Is there any way one can test if the argument passed in to a ByRef (that is ref or out in C#) parameter has the same storage location as some "other" variable? I don't mean to test…
Jeppe Stig Nielsen
  • 60,409
  • 11
  • 110
  • 181
2
votes
1 answer

When IQueryable is created from a linq query why is it not a "new" variable?

I am using the Entity Framework and have got a loop that looks at a set of People and using a foreach loop creates a query for the address of each person. As each address query is created it is added to the node of a treeview where it can be later…
Calanus
  • 25,619
  • 25
  • 85
  • 120
2
votes
1 answer

converting vb.net to c#- optimise parameter passing

I want to move a vb.net app to c#. The vb.net app has thousands of byref parameters that should be byval. Does anybody know a way to automate checking whether each parameter passing approach can be safely changed?
daniel
  • 289
  • 1
  • 3
  • 4
2
votes
3 answers

How to reference a class variable from another class in vb.net

I have the following (simplified to make this easy to read) first class: Class MainWindow Private mFile As myFile 'myFile is a class containing a bunch of stuff Sub go() dim editFiles as New EditFiles(mFile) End Sub End…
user1839684
  • 104
  • 1
  • 2
  • 7
2
votes
4 answers

Is it possible to declare a local/class instance member reference variable in VB.net to read/update same object referred by another variable

In C++, it is possible to do: int x; int& foo = x; // foo is now a reference to x so this sets x to 56 foo = 56; But is an equivalent possible in Visual Basic .net (VB.net)? I am aware of the ByRef term in VB.net but I have only seen (and by…
therobyouknow
  • 6,604
  • 13
  • 56
  • 73
2
votes
1 answer

Class Not Updating Variables passed byref

I have a class in vb.net defined as public class A class A is created on Load and gets called once per program loop The constructor for class A includes the argument (byref Value as long) I have a global variable called varB that is passed to class…
Tony Raymond
  • 187
  • 10