473,406 Members | 2,356 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Simpleton object returning Array problem

Hi All!
##### I have a class clsQProductItem with function GetAllFromInvoice:

Friend Function GetAllFromInvoice(ByVal Invoice As String) As
clsQProductItem()
' Dim retObject() As clsQProductItem = New
clsQProductItem

Dim DataConn As New DataConn
Dim DT As New DataTable
Dim iRowNum As Integer

'Step1: Get all productItems belonging to Invoice
Try
DT = DataConn.RunCmd("Select * from '" & TableName & "'
where invoice = '" & Invoice & "'")
Dim retObject(DT.Rows.Count) As clsQProductItem
'retObject = New clsQProductItem
While Not (DT.Rows(iRowNum).HasErrors)
With retObject(iRowNum)
.ProductItemID =
DT.Rows(iRowNum).Item("ProductItemID").ToString
.Product =
DT.Rows(iRowNum).Item("Product").ToString
.Invoice = Invoice
.Quantity =
DT.Rows(iRowNum).Item("Quantity").ToString
End With
iRowNum += 1
End While
Return retObject
Catch ex As Exception
EventLog1.WriteEntry("Error in cls" & TableName &
".GetAllFromInvoice: " & ex.Message)
End Try
End Function

###### Trying to call this function from a Form:

Dim QProd() As clsQProductItem = New clsQProductItem() {}
QProd = DirectCast(QProd.GetAllFromInvoice(CurrentQinvoice ),
clsQProductItem())

###### I get a squiggly line with message 'GetAllFromInvoice' is not a
member of 'System.Array'

###### Tried this also, gives same error

Dim QProd() As clsQProductItem = New clsQProductItem() {}
QProd = QProd.GetAllFromInvoice(CurrentQinvoice)
Nov 21 '05 #1
2 1131
On 26 Oct 2004 07:56:19 -0700, Callisto wrote:

###### Trying to call this function from a Form:

Dim QProd() As clsQProductItem = New clsQProductItem() {}
QProd = DirectCast(QProd.GetAllFromInvoice(CurrentQinvoice ),
clsQProductItem())

###### I get a squiggly line with message 'GetAllFromInvoice' is not a
member of 'System.Array'


That's because QProd is an array reference wheras the GetAllFromInvoice is
an instance method of a clsQProductItem object. I suggest you make the
method shared and call it using the class name. By the way, the cast is
not necessary.
Shared Function GetAllFromInvoice(...) As clsQProductItem()
...
End Function

Dim QProd() As clsQProductItem =
clsQProductItem.GetAllFromInvoice(CurrentQInvoice)
--
Chris

dunawayc[AT]sbcglobal_lunchmeat_[DOT]net

To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
replace certain words in my E-Mail address.
Nov 21 '05 #2
On 26 Oct 2004 07:56:19 -0700, Callisto wrote:

###### Trying to call this function from a Form:

Dim QProd() As clsQProductItem = New clsQProductItem() {}
QProd = DirectCast(QProd.GetAllFromInvoice(CurrentQinvoice ),
clsQProductItem())

###### I get a squiggly line with message 'GetAllFromInvoice' is not a
member of 'System.Array'


That's because QProd is an array reference wheras the GetAllFromInvoice is
an instance method of a clsQProductItem object. I suggest you make the
method shared and call it using the class name. By the way, the cast is
not necessary.
Shared Function GetAllFromInvoice(...) As clsQProductItem()
...
End Function

Dim QProd() As clsQProductItem =
clsQProductItem.GetAllFromInvoice(CurrentQInvoice)
--
Chris

dunawayc[AT]sbcglobal_lunchmeat_[DOT]net

To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
replace certain words in my E-Mail address.
Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Arne Kösling | last post by:
Hi ! I am new to Web Services. Therefore I ve set up a PHP Installation on Windows (PHP 4.3.2 and Apache 1.3.29). I have tested PHP alone and then installed PEAR. Now I am stuck there (Before...
2
by: Asad Khan | last post by:
Hello, I am writing a method that returns an array as an Object. Initially there is a single dimension array Object X. However, I can insert other arrays as Objects in X, thus I can end up with...
9
by: justanotherguy63 | last post by:
Hi, I am designing an application where to preserve the hierachy and for code substitability, I need to pass an array of derived class object in place of an array of base class object. Since I...
16
by: sneill | last post by:
How is it possible to take the value of a variable (in this case, MODE_CREATE, MODE_UPDATE, etc) and use that as an object property name? In the following example I want 'oIcon' object to have...
3
by: Rich | last post by:
Hello, I am converting an app from VB6 to VB.Net and have encountered the following problem. I have the following loop which retrieves objects from a collection of objects. Dim entry As...
0
by: Callisto | last post by:
Hi All! ##### I have a class clsQProductItem with function GetAllFromInvoice: Friend Function GetAllFromInvoice(ByVal Invoice As String) As clsQProductItem() ' Dim retObject() As...
2
by: segue | last post by:
How would Singleton help store an array in memory? My understanding of Singleton is that it allows for a class design to have overrides so that depending on the request the singleton class can...
1
by: viz | last post by:
hi, i am curious about simpleton classes. i want to know that is it sensible to derive from a simpleton class or should they be used directly. please help Thanx
15
by: Aggelos | last post by:
Hello, I am using php4 And I have a class product I create an array of productObjects that has 2 dimensions. Generraly I am sorting my objects inside arrays and I need to some how recurse those...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.