.net - Using NMock With ByRef Parameters?

Apr 29, 2009

I have to work with an API that uses a lot of by-reference parameters. I'm just beginning to use NMock, and I'm having trouble seeing how to make NMock actually modify one of those by-ref parameters to a specific value. Am I missing something, or does it just not do that? Is there a better way, short of wrapping this API?

View 1 Replies


ADVERTISEMENT

Detect Casted Parameters Submitted ByRef?

Mar 29, 2011

Is it possible to possible to make the following code to produce an error at compile time? (please see the line marked by the comment):

Option Strict On
Option Explicit On
Module Module1

Private Sub Test(ByRef i As Integer)

i = 999
End Sub

Sub Main()

Dim o As Object = 5 expecting an error message like in C# "A ref or out argument must be an assignable variable"Test(CInt(o))System.Console.Out.WriteLine("Testvalue: {0}", o)End Sub

View 7 Replies

Pass ByRef And ByVal Parameters In Same Routine?

Dec 7, 2010

Is it considered bad practice (VB.NET or any language) to code a function with both ByVal and ByRef parameters as used in my getFile function below?

Function getFile(ByVal channel As Integer, _
ByRef Filename As String, _
ByRef Filesize As String) As Integer
End Function
Dim status As Integer

[Code]...

View 1 Replies

Passing Tabpage Controls As ByRef Parameters

Jun 29, 2009

I create tabpages at runtime each having a flexgrid controls. I need to pass these flexgrids of each tabpage as a parameter to a function byref. This is the code .

[Code]...

View 8 Replies

VS 2008 Passing Parameters - ByVal/ByRef?

Dec 22, 2010

I have some code that is transforming the coordinates of a line.I want to keep the original coords and I thought passing the line ByVal would be the best way.The original VB6 code used a temporary variable so that the original coords were not updated.I'm confused as when the X & y coords of 'line' are changed 'MyLine' is also changed. I had assumed only 'line' would change and 'MyLine' would remain unchanged'.

Private Sub TransformSaveLine(ByVal MyLine As LineType)
Dim P As Integer
Dim line As LineType
Dim x As Double

[code].....

View 12 Replies

Function That Takes ByRef Parameters Using Control.Invoke ?

Nov 10, 2005

I'm currently invoking a function that takes ByRef parameters using Control.Invoke (which I notice specifies the Object parameter array to be ByVal) but the array of parameters I give it isn't updated by the function. Is this possible with VB.Net 2003 or must there be some error in my code?

View 5 Replies

How To Use Late Binding To Invoke Method With ByRef Parameters

May 22, 2009

I have a COM component that I want to call using late-binding from VB.NET (using Primary Interop Assembly - PIA method). My IDL signature for the COM method looks like:
HRESULT Send([in]BSTR bstrRequestData,
[out]VARIANT *pvbstrResponseData,
[out]VARIANT *pvnExtCompCode,
[out,retval]int *pnCompletionCode);

So 2 'ByRef' parameters in VB.NET lingo, and a return value. I attempt to invoke this method like so:
Dim parameters(2) As Object
parameters(0) = "data"
parameters(1) = New Object()
parameters(2) = New Object()
Dim p As New ParameterModifier(3)
[Code] .....
This fails spectactularly with an exception: {"Invalid callee. (Exception from HRESULT: 0x80020010 (DISP_E_BADCALLEE))"}

I assume this means I'm doing something wrong in my parameterMods array. Because if I comment out setting any value of the ParameterMods array to 'True' - it works. It of course doesnt update the parameters that are [out] parameters and so it's not working as intended. Is there something else to consider since the method also has a return value? The MSDN example pretty much does exactly what I am doing, with the exception that example did not have a return value.

View 1 Replies

Limit To The Parameters That Can Be Passed ByVal Or ByRef To A Function ?

Jul 2, 2009

Is there a Limit to the parameters that can be passed byVal or byRef to a function or procedure in vb .net ?

[URL]

View 2 Replies

C# - Search For Names In The Database That Matches Whole Parameters Or Any Part Of Parameters

May 13, 2011

I'm writing a query to select all records that has any part of parameter. I have one table called Employees. Some people have name like this: John David Clark If the parameter is

[Code]....

I should be able to get result back as long as there's a match in the parameters. If I use Function Contains (q.FirstName & " " & q.LastName).Contains(employeeName), I will not get any result back if employeeName is "John Clark" Function Contains looks only for next words from left to right. It doesn't match a single word at a time. So that's why I used this in the Linq to SQL:

[Code]....

View 2 Replies

Byref New Object - Top Pass New Object As "byref"?

Sep 7, 2009

Below I tried to do an Example:

[Code]...

Below is the called method: Friend Sub SplitOU2(ByVal inDN As String, ByRef OUDN As Object, ByRef Organisation As Object, ByRef VerksamhetTyp As Object) By doing this I can skip to declare the in this example "useless" variable Dim VerksamhetTyp as Object = "".

View 3 Replies

Error [07002] The # Binded Parameters < The # Of Parameters Makers

Aug 30, 2010

I am getting error [07002] the # binded parameters < the # of parameters makers, i checked both parameters were perfect even though i am getting this error here is my code

[Code]...

View 1 Replies

C# - Difference With Parameters.Add And Parameters.AddWithValue?

Feb 6, 2012

Basically Commands has Parameters and parameters has functions like Add, AddWithValue, and etc. In all tutorials i've seen, i usually noticed that they are using Add instead of AddWithValue.

[Code]...

since it saves my coding time. So which is better to use? Which is safe to use? Does it improves performance?

View 2 Replies

Get The GET Parameters And POST Parameters In Just One Function?

Aug 6, 2011

is there a way to get the GET parameters and POST parameters in just one function or Collection in ASP.NET? Like using $_REQUEST in PHP? I'm using VB.NET.

View 3 Replies

When To Use ByVal And ByRef

Nov 17, 2011

I am a student and i get confused when i see a lot of ByRef and ByVal arguments in a sub procedure. Can someone make it simple for me to understand when it should be used?

View 9 Replies

.net - ByRef Vs ByVal Clarification?

Dec 8, 2010

I've read a lot on this, but am having a hard time thinking through this tonight. (Maybe it's the hydrocodone... just had a root canal. i'm just starting on a class to handle client connections to a TCP server. Here is the code I've written thus far:

[Code]...

Now, on my Socket property, when setting the value, it is required to be ByVal. It is my understanding that the instance in memory is copied, and this new instance is passed to value, and my code sets _Socket to reference this instance in memory. Yes?

If this is true, then I can't see why I would want to use properties for anything but native types. I'd imagine there can be quite a performance hit if copying class instances with lots of members. Also, for this code in particular, I'd imagine a copied socket instance wouldn't really work, but I haven't tested it yet.

View 3 Replies

Asp.net - .Net, EventArgs, ByRef And ByVal?

Dec 15, 2011

In VB.Net, I have an object named WorkflowButtonEventArgs that inherits from System.EventArgs.The WorkflowButtonEventArgs class contains two ByRef Properties. These are objects that are in memory, and I do not want them duplicated or copied in any way.

Can I pass the WorkflowButtonEventArgs object ByVal in VB.Net and have it still preserve the two ByRef definitions in WorkflowButtonEventArgs?Specifically, if I pass it ByVal:

Dim e As New WorkflowButtonEventArgs e has some ByRef properties RaiseEvent SomeEventName(e) ' e is passed ByVal Will the ByRef Properties/Members in e (WorkflowButtonEventArgs class) not be copied or duplicated in memory?

Long-story-short: Can I pass e ByVal, or do I need to pass it ByRef since it contains ByRef Properties?

View 3 Replies

ByRef Not Carrying Through IN Program

Oct 20, 2011

The one calls form 2 as a dialog, and passed by ref a "pointer" to the base class(abstract).[code]...

View 2 Replies

Difference Between Byref And ByVal

May 4, 2010

[Code] What is the difference between ByRef and Byval in this function. When i call this function and debug it it shows no difference the two. Can any one explain me actually what happens.

View 8 Replies

Difference Between ByRef And ByVal?

Feb 20, 2009

ByRef (a.k.a. By Reference) points to where the object is in the memory. Any changes made to the object sent ByRef should change the values of the original object ByVal (a.k.a. By Value) points to a copy of the object. Any changes made to the object shouldn't change anything in the original object

Let's make an example:

Private Sub FormLoad()
Dim a As String = "A"
Dim b As String = "B"

[code]...

The second messagebox shows Baaaa - Buuuu instead of the expected A - Buuuu... but why is that? Apparently ByVal and ByRef does exactly the same thing. It seems like it sends the reference to the object when using ByVal, instead of making a new object.

View 2 Replies

Difference Between ByVal And ByRef

Mar 27, 2012

Whenever I'm going to use a new API, I have to decide for each value whether I'm going to use byval or byref. Can someone explain me in what scenarios I should use which and why? Because lacking this knowledge kinda gives me the feeling of having no control over my code.I am aware about the other threads by people asking the same question, I have read them but its still not crystal clear for me.

View 2 Replies

Difference Between ByVal And ByRef?

Jun 5, 2012

I have seen a few people in the past confused on the usage of ByRef & ByVal in a Function/Sub's Signature. I figured i would make a simple example that demonstrates the difference of each.

Option Strict On
Public Class Form1
Dim A As Integer = 100

[code]....

If you want something you've never had, you need to do something you've never done. If you believe something to be true, then one day you will be called upon to demonstrate that truth.

View 10 Replies

Is Not Necesary To Indicate ByVal / ByRef Any More?

Feb 9, 2012

I just installed Visual Studio 2010 Service pack (proposed on Windows Update), and I can see a new feature on the "intellisense" that means when I write a Function or Sub in VB.NET it doesn't auto-complete parameters with ByRef or ByVal...

1) Is there anyway that I can configure this option back to how it was before?

2) If I don't specify ByX, which one is used by default? (it seems like it is always ByRef)

View 2 Replies

Store ByRef In A Variable?

Jun 4, 2009

Just wondering if it's possible to store a reference to an object in a variable.

I will elaborate:

[Code]...

View 5 Replies

What Is The Difference Between ByVal And ByRef

Apr 10, 2009

What is the difference between ByVal and ByRef? Please remember to mark the replies as answers if they help and unmark them if they provide no help.Welcome to the All-In-One Code Framework!

View 5 Replies

.net - Workaround - ByRef Parameter Of A Property

Mar 19, 2009

I have a legacy COM-component with an interface declaring a property like this (IDL notation):

[Code]...

This interface is implemented in a calling application written in VB6 like this:

[Code]...

Everyting works fine until I try to do the same in VB.Net. VB.Net refuses to compile code where a parameter of a property is passed ByRef. MSDN says VB.Net doesn't allow such parameters. Is there any way I could implement such a property in VB.Net?

View 3 Replies

.NET Invoke DLL Method With ByRef Arguments?

Apr 3, 2009

Using VB.NET, is there a way to pass a reference argument when invoking a function in a dll.

Suppose I want to pass arg2 as a reference argument, how would I do that?

method.Invoke(obj, New [Object]() {arg1, arg2, arg3})

In other words I want to point arg2 to something else within the invoked function.

View 2 Replies

Assigning The Value Of A Label To A Variable Byref?

Sep 8, 2010

I would like a label to always show the current value of a boolean. This will change a lot of times and would like the label to ALWAYS reflect this.

Is there some kind of way to have the label set to the boolean byref (so its always the same). Currently I'm assigning the label.text = boolean onLoad, so if the boolean changes after that its not reflected.

View 6 Replies

ByRef Parameter With Type Conversion

Mar 19, 2012

I did create a XDateTime class that is able to handle inaccurate date and time. This class has all the CType operators required to convert to and from a string and it has been fully tested during the last months.

[Code]...

View 1 Replies

ByRef Vs ByVal Generates Errors?

Apr 26, 2010

ByRef vs ByVal generates errors!?I had a method that used an Object Function Foo(ByRef bar as CustomObject) as Boolean this method generated errors, because some strange .NET Runtime things changed the bar object, causing its Dispose()al.A lot of time spent to understand the thing(where the ... object is changed), until somebody replaced ByRef by ByVal and object wasn't change anymore when passing to this method.As in my case the function Foo does NOT modify the bar, shouldn't ByRef or ByVal have the same effect?[code]

View 4 Replies

C# - .NET Interop Passing VB6 Form ByRef

Oct 11, 2011

I am trying to develop a .NET class that updates a VB6 Form and its controls with various new captions (It is in an assembly that is COM visible).

I pass a VB6 form ByRef as an object to the .NET class and then update the caption etc on the form as follows:

Public Sub AddFormRefLegacy(ByRef objForm As Object)
Try
objForm.Caption = "some new caption"

[Code].....

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved