473,656 Members | 2,793 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 GetAllFromInvoi ce:

Friend Function GetAllFromInvoi ce(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.Ro ws.Count) As clsQProductItem
'retObject = New clsQProductItem
While Not (DT.Rows(iRowNu m).HasErrors)
With retObject(iRowN um)
.ProductItemID =
DT.Rows(iRowNum ).Item("Product ItemID").ToStri ng
.Product =
DT.Rows(iRowNum ).Item("Product ").ToString
.Invoice = Invoice
.Quantity =
DT.Rows(iRowNum ).Item("Quantit y").ToString
End With
iRowNum += 1
End While
Return retObject
Catch ex As Exception
EventLog1.Write Entry("Error in cls" & TableName &
".GetAllFromInv oice: " & ex.Message)
End Try
End Function

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

Dim QProd() As clsQProductItem = New clsQProductItem () {}
QProd = DirectCast(QPro d.GetAllFromInv oice(CurrentQin voice),
clsQProductItem ())

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

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

Dim QProd() As clsQProductItem = New clsQProductItem () {}
QProd = QProd.GetAllFro mInvoice(Curren tQinvoice)
Nov 21 '05 #1
2 1150
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(QPro d.GetAllFromInv oice(CurrentQin voice),
clsQProductItem ())

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


That's because QProd is an array reference wheras the GetAllFromInvoi ce 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 GetAllFromInvoi ce(...) As clsQProductItem ()
...
End Function

Dim QProd() As clsQProductItem =
clsQProductItem .GetAllFromInvo ice(CurrentQInv oice)
--
Chris

dunawayc[AT]sbcglobal_lunch meat_[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(QPro d.GetAllFromInv oice(CurrentQin voice),
clsQProductItem ())

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


That's because QProd is an array reference wheras the GetAllFromInvoi ce 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 GetAllFromInvoi ce(...) As clsQProductItem ()
...
End Function

Dim QProd() As clsQProductItem =
clsQProductItem .GetAllFromInvo ice(CurrentQInv oice)
--
Chris

dunawayc[AT]sbcglobal_lunch meat_[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
4404
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 that, I had many problems with the PHP-dlls) I've set up several SOAP Testscripts that I found on WebSites and in PHP-Books to get a PHP Client and a PHP Server communicate over Web Services (using PEAR::SOAP).
2
18665
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 something like following: ------------------------ | A | B | C | Null | D | ------------------------ | R |
9
4791
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 am using vector class(STL), the compiler does not allow me to do this. I do realize there is a pitfall in this approach(size of arrays not matching etc), but I wonder how to get around this problem. I have a class hierachy with abstract base...
16
25404
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 the properties: mode1, mode2, and mode3. This seems simple but I can't quite figure it out... Any ideas anyone?
3
3981
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 Domino.NotesViewEntry Dim obj As Object, str1 As String .... For Each obj In entry.ColumnValues.ToString
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 clsQProductItem = New clsQProductItem Dim DataConn As New DataConn Dim DT As New DataTable
2
960
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 respond in more than one way or create more than one type of instance dependent on the singleton class request. Should I be worried about creating an in memory array object that: Can be called concurrently from multiple in this case web page...
1
1832
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
1922
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 arrays to get to the objects. To do that I am using the following method recurseArray() function recurseArray($array) {
0
8816
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8717
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8498
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8600
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7311
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4150
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4300
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
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 we have to send another system
2
1600
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.