Passing Class ByRef Doesn't Act Like Expect It To
Dec 31, 2009
This is the code:
Public Class userDefClass
private b as integer = 1
End class
Public Class Form1
private SomeClass as new userDefClass
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) [Code]...
View 7 Replies
ADVERTISEMENT
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
Jul 23, 2010
I have been working on this for a few days, and I am going around in circles. I can make the program work by including everything in the same sub procedure, but the assignment requires that I do certain tasks by using function procedures.What I need to do is take the contents of a text box, reverse the order of the first and last names, and add them to a list box. I can do that, just not by passing value from a function procedure. Here is my
View 4 Replies
Jan 31, 2012
I am trying to create a Library for like code that we use in more than one application. One call involves an array where I need to create a pointer to the array for what I need.
Is there a way to pass a value ByRef, have it increment, and return the value back to the original call?
View 35 Replies
Jul 22, 2010
Reading [URL] made me wonder whether the comments in there did apply to Strings in terms of performance. Since strings are copied before being passed, isn't it much more efficient (if the callee doesn't need a copy of string course) to pass strings ByRef?
[Code]...
View 1 Replies
Jan 9, 2010
I have a C# interface defined as so:
public interface IMenuSecurityService
{
void SetSecurityFlags(List<MenuItem> items);
}
I need to implement this interface in a VB.Net class. When I implement the SetSecurityFlags method with the items parameter passed ByVal, it compiles.
Public Sub SetSecurityFlags(ByVal items As List(Of L1.Common.Model.MenuItem)) Implements IMenuSecurityService.SetSecurityFlags
' do some work
End Sub
When I try to implement it with the items parameter passed ByRef, I get the following compiler error: Class 'UserRights' must implement 'Sub SetSecurityFlags(items As System.Collections.Generic.List(Of Model.MenuItem))' for interface
Public Sub SetSecurityFlags(ByRef items As List(Of L1.Common.Model.MenuItem)) Implements IMenuSecurityService.SetSecurityFlags
' do some work
End Sub
I can't seem to figure this one out. Does VB.Net not support this or am I doing something wrong?
View 1 Replies
Sep 14, 2010
In VB6.0, you could create a sub that took an array byref, and then call it with an argument that was an indexed element of the array, and it would treat that index as the starting point. This was very useful, for example, if you were trying to create a binary string to send over a communication port.The same thing doesn't work in VS 2008,Let us say for example I have the following Sub:
Public Sub HexToAddr(ByRef addr() As Byte, ByVal addrstr As String)
Dim i As Integer
For i = 0 To 7[code]....
Is there some tricky way to make this work, or do I really have to either (a) create a completely separate array of bytes, call the function, and then copy the data, or (b) create a completely separate version of HexToAddr which takes an "offset" argument for the destination array?
View 12 Replies
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
Jun 6, 2011
I have a function that accepts a String by reference:Function Foo(ByRef input As String)
If I call it like this:
Foo(Nothing)
I want it to do something different than if I call it like this:Dim myString As String = Nothing Foo(myString) Is it possible to detect this difference in the way the method is called in VB .NET?All the logic is in the second overload, but I want to perform a different branch of logic if Nothing was passed into the function than if a variable containing Nothing was passed in.
View 3 Replies
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
Aug 18, 2009
I have some classes, BsfciFile and StudyFlashCard. Bsfci is the extension to which I save my set of flashcards in an INI format. I am currently working to transform my code from using Windows API calls to access the INI to using a IniFile class that I found on the internet. I would like the BsfciFile to have a Array of StudyFlashCard objects, but I would like the StudyFlashCard class to use the IniFile class object contained in the BsfciFile class. I can pass the IniFile from the BsfciFile class to the constructor for the StudyFlashCard class, but I want it to modify the same IniFile as the BsfciFile class has later on.
[Code]...
View 1 Replies
Oct 20, 2011
Why if you pass an object as byVal into a method is it then treated as if it were byRef? I know you're only passing the reference across when you pass an object variable but why doesn't VB force you to decalre the header as byRef?
View 2 Replies
May 5, 2012
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 A on creation.
now why when varB is altered during the program loop, the change is not reflected within the class?
View 1 Replies
Sep 27, 2010
I have code, shown below, that works all except for 1 thing: The variables being passed byRef get passed, but once modified in the else section of the "if me.invokerequired" code of RecordData, the variables are never updated in the calling function. To reiterate, the calling function does not receive the updated data that is in the variables custid and amt.When debugging, I see the data change in the else section of "if me.invokerequired", but once it returns from the callback the data is missing.[code]
View 15 Replies
Dec 8, 2009
I am making use of a 3rd party dll and am encountering some strange behavior in VB, which doesn't occur in C# Perhaps someone can explain what is going on. Anyhow, I am making use of a method in this 3rd party library which accepts an array parameter ByRef. The end result is the variable should remain null after the method call, but it is returning initialized for some reason.
[Code]...
View 2 Replies
May 23, 2011
I have a WCF Service exposing a single contract and operation:
<ServiceContract(Namespace:="ImageSystem")> _
Public Interface IUploadService
<OperationContract()> _
[Code].....
This subsequently leads to stream casting issues, because the generated function allows me to pass a memory stream as an input (which works correctly when passed through to the service), but instead of passing me back a new stream for the response, it attempts to cast the MessageBodyStream received from the service into my memory stream.
This is, in some ways similar to other posts but as you can see, there are no enums involved in my contracts - presence of Enums caused strange proxy class generation is marked as the answer in the similar post.
Is there anywhere I configure the proxy behaviour to use the contracts I've specified? Clearly I'm within a dev/test environment currently, but when this eventually goes to production it will be memory and file streams passed to the service, and the returned stream can be in any format to be honest, I intend to treat it as the abstract stream class. The only way round this I can see right now is to change my in stream to be the same as the anticipated out stream, but surely there is a better way?
View 1 Replies
Jun 21, 2012
the code on select.aspx.vb are
Imports System.Data
Imports System.Data.SqlClient
Imports System.Web.Configuration
[Code]....
I am trying when select Listbox with ID="lstAuthor" the label box will pass the value but it failed to show.
View 1 Replies
Apr 22, 2012
Base class has one field to hold numeric balance value. With 2 methods that accept arguments for adding and subtracting the new input calculating new balance. Sub class has four fields dates, transaction, memo and amount.I have a deposit form, and withdraw form. Each time one transaction is entered it creates an object with sub class fields, then adds to the account collection. My problem is not understanding how to call the deposit/withdraw method and pass the current transaction amount back to the base class to alculate the new balance. Does anyone have any links to information/tutorials on how to perform something like this? As you can see with my code I have tried various different approaches without any success.
[Code]...
View 5 Replies
Apr 7, 2010
I'm sure there are several ways of achieving my goal but I am after opinions on what you think is the best option. I'm writing a vb.net application which (amongst other thinks) interfaces with media players in the home. Because there are different types of media playersI'm trying to structure it so each type of media player has it's own class which interfaces to a management class which sits on top of all the different devices types.
The device classes are responsible for discovering the phsyical devices and returning that information up to the management class. A device class may be responsible for monitoring 1 or more physical devices so..
[Code]...
View 1 Replies
Aug 11, 2009
Is it really impossible to create an extension method in C# where the instance is passed as a reference?
Heres a sample VB.NET console app:
Imports System.Runtime.CompilerServices
Module Module1
[code].....
View 3 Replies
Apr 28, 2009
I seem to have problem with passing a collection/sorted list/ list of strings from one class to another.I am using property procedure to pass it, however nothing is sent to another class. There isn't any error messages either.[code]
View 3 Replies
Feb 18, 2010
Hi
I've got a pretty general question about the best practice in passing an object reference to a Form in VB.NET. My form is a dialog and I've created an overload ShowDialog method, where I pass an Object into it ByRef.
The trouble is, I want to be able to refer to that Object throughout my dialog Class and not just in the ShowDialog method. For instance, some of my Events for controls on the form, need to reference that object.
I know I could create a local Private variable in the Class and assign it to the passed value, and then use that value. However I'm thinking this isn't very efficient because it would (I believe) create a new copy of the Object (which is a complex, large class in itself).
View 8 Replies
May 24, 2010
If we format a value for percent "{0:#%}" then it will become 400%, and this also applies to all the 3rd party controls I've tried. I've used custom format as a workaround for this but perhaps you guys could enlighten me on this one. If a user inputted 4 for example then did the user intended 4% or 400%? If it were me that I would expect the 4 to be 4% rather than 400%.
View 11 Replies
Jul 4, 2011
In a VB 2010 program we have two classes Aclass and Bclass.In Bclass we need all values of an Aobject.How could we pass the Aobject to Bobject?[code]Is there any VB entity that could be defined as including all the properties of a given class?
View 3 Replies
Aug 14, 2009
how to pass arraylist value in to another class?
View 8 Replies
May 12, 2010
How do I pass a structure containing strings from VB.net to VB6. I can get an integer to work but not a string.
View 3 Replies
Mar 10, 2012
what i am trying to do is pass the values username and password to the Private Sub XMLReg. the username come from a textbox then is passed to Property newUserName() and password is taken from a textbox and passed to Property newPassword() but how do i pass the values of both to XMLReg() and where would i call xmlReg?
My code:
Private Sub getUsersDetails()
Dim userName As NewRegs = New NewRegs
userName.newUserName = txtUsernameReg.Text
[code].....
View 2 Replies
Apr 19, 2009
If I type this code (VB.net 2003):
Dim myDialog As frmTestDialog
myDialog = New frmTestDialog
myDialog.Show()
you'd expect some dialog window to appear in a non-modal state. For some reason, this isn't the case with a program I am working on. Most of the dialogs use ShowDialog() to open them, and one uses Show(). The second I try to show another non-modal dialog, the dialog appears in a modal state. Another strange thing is, before I show the dialog, there is code to shift the dialog location to centre it on the main form - this isn't executed either: the dialog appears at 0,0.
My usual trend is to blame myself for errors (usually the case), then I blame the software; I have checked every single line of code (including the generated code), and it all checks out - the dialog should be non-modal. But ... it's not. I've come across other errors in VB.net 2003; is this another instance?
I'll try creating a new dialog and displaying this non-modal, and see what happens. If it works, I can just transplant the code but this shouldn't be happening, just like if I go to a shop, ask for a cola, I expect a cola not a Chinese panda; more annoying, I return the panda, ask for a cola, and they give me the panda back do loop until I give up The system does using threading, but none of that code connects to the display dialog routines all dialogs are opened with more-or-less the above code (a few have simple validation routines).
View 5 Replies
Feb 9, 2012
Take the below example. I would expect the IsInterned method to return null, because this string can't possibly be in the intern pool having started up the test app for the first time? I would also expect, that if I did something like string.intern("this112233StringCan'tPossiblyBeInTheInternPool!£$%") first, then this would legitimately be returned by IsInterned from the pool. I've also done the same in c# and the behaviour is the same.
Whenever I use strings in code, I tend to do something like textbox.text = string.intern("someValue") etc or if (textbox.text = "someValue") etc. Infact, whever strings are being used, I've gotten in to the habbit of using string.intern. Is this a bad habbit rather than using constants or the resources file?
[Code]...
View 19 Replies
Dec 3, 2009
After right clicking on the form Context Menu give option to see 'View Code Window' which opens the the view code window and shows from the first line of code in the file, where actually it should show Event handlers related to the control on which Mouse was right clicked. right now we have to go through the line of codes to locate the event related to particular control.Also after double clicking on the control, VB inserts a default event handler to Code file which should happen only when there is no Event Handlers added for that control previously & if a previously added Event Handler present, double clicking controls should locate that procedure.[code]after dragging dataset table to the form vb assigns 'field name' concatinated with 'TextBox' to TextBox Control likewise 'field name' concatinated with 'ComboBox' for ComboBox Control where it is difficult to locate them in Controls Member list into code..Instead why don't you prefix them with 'txt' for TextBox, 'cbo' for ComboBox etc. It is then easy to find one in code. Or make the original Optional.
View 7 Replies