Passing Tabpage Controls As ByRef Parameters
Jun 29, 2009I 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]...
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]...
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].....
I would like to know if it is better to pass a listbox for control to a module with SQL stored procedure or to use the List(of ) function.
example:
in the form class---
SQLModule.getPartSearch(txtGroupID.Text.Trim(), txtFirst.Text.Trim(), txtLast.Text.Trim(),
[Code].....
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 RepliesIs 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
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]...
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].....
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 RepliesI 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?
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 RepliesI 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.
Is there a Limit to the parameters that can be passed byVal or byRef to a function or procedure in vb .net ?
[URL]
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]...
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?
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]...
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?
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.
I' havea doubt on vb.net windows applicationwhile im using tab pages when i 'm moving fromabpage1 to tabpage2 all the controls in tabepag2 must be cleared(if checkbox is checked ,it should be unchecked when we move to tabpage2
View 3 RepliesI am using Visual Studio 2008 and recently a weird bug has appeared.In my forms I have a tab control with multiple tab pages. I can place a control on a tab page fine, but when I move it by way of clicking it and dragging it to another location, it leaves behind an outline of where it should be. Looking around, it has moved to the first tab page
View 2 RepliesI'm having a lot of trouble trying to add a new control to a dynamically created TabPage at run time, I have viewed many threads with similar help requests and cant seem to make the codes work!
Here's what I've got:
Dim albumscount As Xml.XmlNodeList
albumscount = config_doc.SelectNodes("component/config/menu/album")
i = albumscount.Count - 1
Dim albumtitle As Xml.XmlNode
[code].....
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 RepliesI 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]...
I have VB 2008 Express and I am also new to VB. My problem is I cannot find any assistance with creating an Event that is attached to a Control that I inserted on a dynamically creeated TabPage. I call the "create_tab" sub (below) that creates a New TabPage and add some Controls (Button, two textboxes). Now, that I have the TabPage (and there could be multiple), I want to bind an Event to these items. So when a user Clicks on the Button in TabPage1, for example, a Sub executes where I can manipulate the data contents of the textboxes. Here's My code that creates the tabpages dynamically.
[Code]...
I'm trying to learn VB and don't understand what is wrong with this code?
Private Sub ScoreRange(strStart as String, strStop As String)
Dim MyCell As Range
For Each MyCell In Range(strStart & ":" & strStop).Cells
[code]....
to solve my problem regarding dataset, crystal reports and exporting to pdf file? There are datas when i preview the crystal reports but when i export it to pdf viewer there's no data displayed. Here's my
DataOpen()
cmd.CommandText = "Select * From AllDTR Where BIOID = '" & myuser & "' AND Date > '08/31/2009' ORDER by Date"
[code].....
I have a form with 2 dateTimePickers and a SHOW button which gets data from an sql server database and displays it in a DataGridView. this works ok. I also have an EDIT button which brings up another form with textbox and comboBox controls displaying this one record. I want to be able to click in the DataGridView to select a Name and then click on the EDIT button to bring up the selected record. I don't know how to pass the ID as a parameter to this second form. Apart from that the EDIT button works, in the sense that I hard coded the ID (32 or 35 etc.) and it brings up the appropriate record. But how do i pass the selected ID. [Code]
View 2 RepliesI have a DataSet1.xsd This is connected to my access DB through OleDB. the DataSet Designer is stating that my column in my table is of type Double. Which is true when I verify it by opening Access and viewing that same column in my table.
I need to pass a parameter to my fill query so that on formload it populates the controls. I create the parameter in the dataset designer and give the paramter a name and specify the proper data type.
I edit the query to include the parameter.
on form load the generated code from the dataset designer inserts the fill command for the table adapter but doesn't include the parameter data, so I manually insert the data to be passed to the parameter.. This is where I get an error stating that datatype mismatched..
However the datatypes are correct.
[code]This works fine and passes 8 parameters into the sysimp.bat file. The problem is if I try to pass in a value that has a space between the text then it will treat it as two parameters rater than one.So if P1 value is for example "Hello World" then when passed into the bat file it will assign "Hello" to P1 & "World" to P2. Is there a way to wrap the text in the parameters or should this be done in the .bat file?
View 9 RepliesI designed a form simply holding a combo box, button & Datagrid, working well when executed from another erp application.Now i would like to get parameters from the application and pass on to the form. The parameter has to replace the value of Combobox value.
View 3 RepliesI need to call a function in an unmanaged .dll written in C lang from vb.net. The function declaration looks like this [code]Now the behavior of this function is that it copies some data in argument "reply" and returns a numeric value which signals its pass/fail status. How do i pass it a string object so that it can copy data. Following is how i access this function.[code]When the call completes, returned status is absolutely fine but there is nothing in string "str". What is it that i am missing. I'm not sure about the string object that i am passing as argument.
View 3 Replies