473,503 Members | 3,739 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1135
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
4396
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
18654
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
4765
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
25390
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
3970
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
251
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
951
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
1812
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
1890
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
7064
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
7261
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
7315
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...
1
6974
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7445
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
5559
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4991
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...
0
1492
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
369
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.