Passing List (Of ChildClass) As Parameter To Method Expecting List (Of ParentClass)?

Apr 12, 2010

I have implemented inheritance for two parent classes called Table and Field. Each parent class has several child classes. In the Table parent class, I created a method that expects parameter List(Of Field).

I get an error when trying to pass in parameter List(Of ChildField) to the method that expects a parameter of List(Of Field). The error message is as below:

Value of type
'System.Collections.Generic.List(Of
com.hlb.icisbatch.data.ChildField)'

[Code]....

View 2 Replies


ADVERTISEMENT

Populate A List(Of Object) In A Class Method, Where The List Was Passed To The Method As A Parameter

Aug 13, 2011

I'm trying to code a class of RandomNumber. One of the class methods needs to populate a "List (Of RandomNumber)" ... which was passed as a parameter to the method ... with 10 random numbers between 1 and 50. DEAD SIMPLE :)

View 6 Replies

Sql - Passing Comma Delimited List As Parameter To IN Clause For Db2 Query Using Designer In 2008?

Mar 26, 2009

I want to pass a comma delemited list of values as a parameter to a query I'm building using the designer in Visual Studio 2008 based on some strongly typed DAL tutorials I was going through. The query is going against a DB2 database. Here's what I want to do:

select * from prices where customer in(?)

It works fine win I pass in 123456 as ?But fails when I pass in '123456' (it is a char field so I don't know why this doesn't work; it must be adding these behind the scenes) or 123456, 123457 or '123456', '123457' I'm adding this page to a portal where all the data access is being done based on the DAL designer model with a BLL that calls it so I wanted to do it this way for consistency.

View 1 Replies

Get Type Of Derived Generic List Class From List Item Method?

Mar 23, 2011

Public Class notifierMain
Public Class Contacts
Inherits List(Of row)
Public Sub New()

[code]....

When I debug this winforms application I get curType = "notifier.notifierMain+Contacts+row" I want to the Validate function to know it is in MyContacts. How do I do this?

View 3 Replies

.net - Passing A Method (that Returns A Value) As A Parameter A Bad Thing?

May 21, 2012

So for instance I have this method: LoadFunkyInfo(byval funkyData as string) And I pass it something like this:

LoadFunkyInfo(giantTable.Rows.Item(0).Item("blahName")). Should I do this instead?

dim foo as string = giantTable.Rows.Item(0).Item("blahName")
LoadFunkyInfo(foo)

I read somewhere long ago, that it's better to assign the method to a variable and pass that variable to a method, as opposed to passing the method as a parameter. Is that still true? Or true at all?

View 5 Replies

Passing Parameter (Value Or Referenced Type) Into Method?

Nov 11, 2009

What happened when parameter passing. Here is a test project I write.
Public Class Form1
'1.test string
Private Sub btnString_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnString.Click
Dim str1 As String = "x"
[Code] .....

From the project you can see, when pass integer type parameter (value type) into a method , if use ByVal keyword, the value won't change. If use ByRef keyword, the value will change (I can understand it, to my understanding, when using ByVal, It pass the value of the argument to the method; when using BvRef, it pass the address of the argument to the method, so the value can be rewrite)

Well, for the following two scenarios , I can't understand why.
String type is reference type, but it acts like integer type.
Val type is also reference type, but no matter what you use(ByVal or ByRef), the result will be the same.
So my question is what actually passed into method? What's the underlying mechanism about pass parameter? What's the effect of ByRef and ByVal to value type and reference type?

View 1 Replies

Passing Date Parameter To DataTable.Select() Method

Apr 9, 2009

Jst recently i came across the select() method of data table and felli n love with it instantaneously.

Basically I want query the data table on a date field, unfortunately the format of the date string returned from y database in to data-table and the date string i'm passing as inputs are different.

How can i make sure that the data is compared irrespective of the formats ? Can I use something like SqlParameters whoes data type is date for comparison ??

this is what i'm tying :

dim dat as date = "#1/3/2009#"
dt.select("StzDate ='" & dat "'")
entry in datateable dt : StzDate : 3/1/2009 12:00:000
Am I do'in something wrong ??

Also, can anyone redirect me to some site where I can learn a bit more about passing parameters to the select statement,etc...

View 2 Replies

.net - Passing Bytes To "ParentClass"

Jan 3, 2010

I have a class which get all the bytes from a file, then it splits up the bytes into three parts (a header, index and body) these 3 parts get passed along to 3 classes (called header, body and index) respectively. When the bytes in the three classes gets modified how can I pass these changes back up to the first class (the one that got the bytes from a file). Must I have a property in each of the head, index and body classes called parentclass and then set the property when the classes are created? This could get chaotic when the 3 classes are split up further.

A file is loaded and the bytes put into a property called data() then the bytes are split at certian places/offsets into three parts. One part gets put into a property called data() in a class called header the other two part are also put into properties called data but in another two classes called body and index.
The user, through the form ui, modifies the data in the 3 classes (header, index and body) I want this data to be passed back to the first class combined and then it can be saved as a file.

Or I just want to be able to referenc the data.

View 3 Replies

Passing A List's Enumerator To A Function

Dec 2, 2011

It looks like passing a list's enumerator to a function "byval" is quite different than passing it "byref". Essentially, regular "byval" passing will NOT change the caller's "enumerator.Current value", even if the function advances the enumerator. I was wondering if anyone knows why this is the case? Is an enumerator a primitive like an integer, without an object reference, and hence changes to it don't get reflected in the caller?This function is byval, and gets stuck in an infinite loop, spitting out "1" message boxes, because the enumerator's "current" never advances past 5.[code]The difference between the two functions is only whether the listFirstItem__ function accepts a byval or a byref enumerator.

View 2 Replies

Passing Parameters In SQLParameter As List?

Feb 8, 2011

I'm a beginner in VB.NET programming.. Please help me on how to pass SQLParameters in the below function..

This my code:

[Code]...

View 1 Replies

Passing Values From A List In Classes?

May 5, 2011

Im having a hard time trying to pass the values from a list inside of a class. Im trying to display multiple lines of values from a list inside of a class. My "client" class stores multiple lines of values into a list(of class transaction), with the number value(num) counting each transaction that it adds to the list.

Code:
Public Class Client
Private m_tranlist As New List(Of transaction)[code]....

im trying to display each line that is stored in the list in a label, and im having major trouble. I know all of the results are added into the lists, but how do i call the list in my main form in order to display each line of all of the values? Would I have to look up an index or something?

View 1 Replies

Have An Optional Parameter Of The Type List?

Sep 25, 2009

Is it possible to have an optional parameter of the type list?Ex.

Private Function TestFunction(Optional ByRef MyList As List(Of Double))

The real problem is giving the list a default value. When dimming a new list, you can use the code below to give it a starting value:

Dim MyList As New List(Of Double)(New Double() {1, 2, 3, 4, 5})

But even after trying many variations of the above code, I cannot get it to work as an optional parameter.

View 16 Replies

Parameter Of Function/sub From A Fixed List?

Nov 28, 2011

I have been a VB user for quite a long time starting from dos-basic types. But only now I encountered with a quite a newb problem :) I tried to search MSDN for it for about a few days and at the end I have to ask this question here because I could not find anything about it.

From time to time I use functions or subs where one parameter is a word from a defined list.

E.g.

private function my_function(byval THE_PARAM as string) as ..........

where THE_PARAM could be "work", "home", "bus", etc. 5 words all together.

How can I define a function so that when I use it on the text of the program I had a hint not just like "THE_PARAM is a string", but I had a choice of those pre-defined words, so I could choose a word from that list.

View 3 Replies

.net - WinForms - Passing Same List As DataSource For Two Different Listboxes?

Dec 30, 2009

Check out the simple code below :

[code]...

What happens is that when the Item2 is selected in the first listbox, the second listbox automatically changes its selected item to the Item2. This happens just the same with the other listbox.

View 3 Replies

Passing List Of (integer) To Select Statement?

Mar 27, 2012

I have a function that returns a Datatable. I am passing a list of Integer as an argument. Then I thought tis would work.

Public Function GetEventsByEventType(ByVal EventType As List(Of Integer), ByVal DayInterval As Integer) As DataTable
Using con As New MySqlConnection(strCon)

[Code]...

as you can see. I use string.join to convert the list of integer to something like this. '1,2,3'. Problem is that is read as a string so i get the incorrect results. I need to have where EventType IN(1,2,3).

View 2 Replies

Passing String Variables In Array List

Jun 12, 2009

I'm having difficulty passing a variables in a an array list. [Code] I have to pass the paramvals array to the function. The paramvals array contains the string but not the value of variable of that name. For example, parmaval(0) should contain the value of vSequence but it showing me that it contains string "vsequence".

View 3 Replies

Search Array List By Passing Just The First Few Characters?

Jan 19, 2010

Following is the format of the data stored in my arraylist.

A-Amsterdam
B- Brussels
C-Canada

so and so forth. I wan to search my array list by passing just the first few characters till '-' So if i have something like AA-Test then i want to pass just 'AA' to check if it exists or not.

I know that i can use contains or binarysearch but it does not serve my purpose as they both compare objects.

View 2 Replies

VS 2008 ByVal / ByRef List Parameter

Sep 4, 2010

I have a class OrderManager, that takes a parameter of type LocalFuturesList on construction. Now.. It doesn't seem to matter if I use ByRef or ByVal here.. It still references the parent class instance of it. It also doesn't seem to matter if I type New or omit it.. Probably also because it's just an address reference. But why is it like this? And what type of objects "acts" in this way? Further I find that if I change the object in the parent class by deserializing from a file (with my method call shown), then suddenly this reference is broken in some way, so the OrderManager instance now holds Nothing I believe.If my observations are correct I see two challenges:

1. How to pass a list NOT by reference?

2. How to maintain a list reference through deserialization? [code]

View 17 Replies

Passing A System.Collections.Generic.List To Another Class?

Jun 10, 2012

I am trying to pass a System.Collections.Generic.List to another class. The collection is created in class2 and then passed into class1

[code]...

However I get a 'Null Reference Exception error' when I run the program. It seems f_str in the line 'For Each s As String In f_str' is null.

View 3 Replies

Passing Checked List View Items Into A Message Box?

Jun 10, 2011

I need help on passing checked list view items into one message box. my current code outputs multiple message box with the name of the item, depends on the number of items checked. what i need is to output into a message box all the items checked in my list view. the items should be posted in multiple lines. is there any way i can do it.

[Code]...

View 2 Replies

Create A List Of A Generic Type That Will Be Passed As A Parameter?

Feb 14, 2011

say I have two POCOs I'm using in EF code first

Public class C1
property F1 as integer
End Class
Public class C2
property F2 as String
End Class

I want to have a function that will create a list either of C1 or C2, to be used in some generic operation, such that

[Code]...

View 1 Replies

Getting A Method Name And Add It To A List

Jan 4, 2012

I am trying to get a methods name and add it to a list. I had a look around and came across actions. So far I have the following:

Protected Function MethodToString(method As Action) As String
Return method.Method.Name
End Function
...
Me.Stages.Add(MethodToString(GetWeightFromSID()))

but it does not work when called as it says expression do not produce a value.

View 2 Replies

Sql - Passing A List Of System.guid As Params To As SQL2008 Sproc?

Sep 24, 2009

I would like to pull a set of records in a SQL sproc by passing in a list of system.guid and also by passing in a list of integer keys.I can put the guids ihto a string, of course, but the question is - how do I quote the test values so they are recognized as UIDs by SQLIn essence I was to DECLARE @pklist AS VARCHAR(1000)-- This would look like "'45F4AE2A-D27C-D711-83FD-0008C7FA9683','EC824D02-D37C-D711-83FD-0008C7FA9683','BA8E4D02-D37C-D711-83FD-0008C7FA9683'" coming out of the execsql from vb .net - I think :-) but it seems it needs to look likeSET @pklist = '45F4AE2A-D27C-D711-83FD-0008C7FA9683,EC824D02-D37C-D711-83FD-0008C7FA9683,BA8E4D02-D37C-D711-83FD-0008C7FA9683'SELECT * from dbo.members WHERE members.cpk IN (@pklist)This only returns the record matching the first UID in the string. Is there something I can wrap a t-sql VARCHAR string with so each guid will be seen distinctly?In trying to do this with a list of integer keys, the problem is the value is seen as part of a string and is not cast to an integerIt would seem creating a table from a parsed version of the string passed in and then doing a JOIN would accomplish what I need as well, but struggling with the T-SQL syntax for that.

View 1 Replies

VS 2010 Sort List Of Objects, Based On Object Parameter

Oct 10, 2011

I made an object that has several properties one of which is an integer.

I put all the objects into a list, and I wish to sort that list by the integer property, with the object with the highest property at item 0, with the object with the lowest property at the highest item # ( count -1).

I made the list of that item, as in

Dim GameList as new list(of clsGame)

And I wish to do something like the following

GameList.Score.Sort()

What is the syntax to do that? I looked up the MSDN and didn't really understand what it was trying to say

View 4 Replies

.net - Add Method Of The List Function?

Jan 2, 2010

I have a data structure (which is a class) called user_class and I want to load all the users data from a database.Currently I have

While SQLreader.Read()
Hold_user.username = SQLreader(0)
Hold_user.BlahBlahBlah = SQLreader(1)

[code]....

Where return_value is a List of user_class and hold_user is an instance of the same class.

Dim return_value As New List(Of user_class)
Dim Hold_user As New user_class

As the while statement loops through the read data, SQLreader(0),(1) and (2) are updated with new data, however they also appear to be updating the stored values held in return_value....

View 2 Replies

InvokeMember Method List?

Feb 20, 2012

I am using the HtmlElement's InvokeMember function and was wondering if there is a nicely formatted list of all the strings that can be passed into that function.So far I know about these strings that can be passed into InvokeMember:Click, Focus provide a link to a list of all strings that can be passed into the InvokeMember function or write them down?

View 1 Replies

Pass A Parameter From The Select List Into A Function For Joining A Linq Query?

May 25, 2010

I have a query that can be summarised in SQL as follows;

Select
S.StockCode
From
StockToCheck As S

[Code]....

Where the S var is a list of strings. This gives the error 'S' is not declared and points to the S in the function call / join (GetPOSStock). So it does not seem possible to do this in Linq, can anyone confirm?

View 1 Replies

Simulating IntelliSense's Parameter List For A Function Call (like MsgBox Button)

Jan 29, 2010

I am creating a function and want to have IntelliSense pop down the list of valid options for a certain parameter in the same way that the MsgBox function behaves when you are typing your argument for which buttons you wish to include (such as MsgBoxStyle.OkCancel). I have done my best to search the internet but haven't found a thing which comes close to what I'm seeking. My monkeying around hasn't produced a satisfactory solution, yet, either.

A related additional thing, which I can live without but that would be nice to have, is the description of the current parameter, which appears below the function description as shown highlighted below MsgBox (Prompt As Object, [Buttons as Microsoft.Visual Basic.MsgBoxStyle = MsgBoxStyle .DefaultButton1], [Title as Object = Nothing]) AsMicrosoft.VisualBasic.MsgBoxResult

Buttons: Optional. Numeric expression that is the sum of values specifying the number and type of buttons to display, the icon style to user, the identity of the default button, and the modality of the message box. If you omit Buttons, the default is zero. This is my first post. I'm relatively new to VB .Net.

View 5 Replies

Scope Of .NET's List(Of T).Reverse Method

Apr 7, 2009

I've got a simple function that takes a List parameter. While working with it, it copies it and reverses the copy using .NET's List(Of T).Reverse method.

[Code]...

View 6 Replies

Using TrueForAll Method In Generic List?

Jun 7, 2009

I have a class myClass. MyClass has a property myName. I have a generic list myList(of myClass). I have to check if value of myName in all myClass objects in myList is same and is equal to a string myString. I have created a method:

Private Function IsMatching(ByVal objMyClass As MyClass, ByVal strMyString As String) As Boolean
If objMyClass.MyName = strMyString Then
Return True
Else
Return False
End If
End Function
Now I want to use is TrueForAll method of Generic list. How can I use it ?

If there was No second Parameter in IsMatching method, I could have simply used
myList.TrueForAll(AddressOf IsMatching)
But since there is a parameter strMyString, I dont understand how can I use IsTrueForAll method. How can I use IsTrueForAll method in this scenario.

View 2 Replies







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