473,654 Members | 2,974 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 1149
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
18664
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
8375
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8290
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8593
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
5622
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4149
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
4294
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2714
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
1
1916
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1593
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.