Hello all,
I received some excellent advice from this forum yesterday concerning structures as opposed to arrays. I had wanted to create an array, and send it to another form to display its contents in a list box. I had assumed that I could pass the structure to the form in the same way I am currently passing strings and integers - but it doesn't appear to be quite as simple.
What I'm getting is an error which says:
???? Can't be converted from a Generic List to a Generic List??Value of type 'System.Collections.Generic.List(Of MyApplication.CalculateResults.Products)' cannot be converted to 'System.Collections.Generic.List(Of MyApplication.DisplayResultsWindow.Products)
As I'm still quite low down on my learning curve, I've hacked it about a bit, and my main form calls a class, which is set up like:
And my form to display the results looks like:Code:Public Class CalculateResults Public Structure Products Sub New(ByVal strID As String, ByVal strQuantity As String, ByVal strValue As String) ID = strID Quantity = strQuantity Value = strValue End Sub Dim ID As String Dim Quantity As String Dim Value As String End Structure Public strProducts As New List(Of Products) Private Sub DisplayResultsWindow(ByVal etc, etc...... Dim frmDisplayResultsWindow As New DisplayResultsWindow With frmDisplayResultsWindow ... a list of some other variables to pass to frmDisplayResultsWindow .ProductsOutOfBalance = strProducts End With frmDisplayResultsWindow.ShowDialog() End Sub
Thanks in advance for your comments.Code:Public Class DisplayResultsWindow Public Structure Products Sub New(ByVal strID As String, ByVal strQuantity As String, ByVal strValue As String) ID = strID Quantity = strQuantity Value = strValue End Sub Dim ID As String Dim Quantity As String Dim Value As String End Structure Public WriteOnly Property ProductsOutOfBalance() As List(Of Products) Set(ByVal value As List(Of Products)) .... still learning, so not sure what I need to do at this point, but I'll figure it out! End Set End Property




Reply With Quote