Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

set of variables

Status
Not open for further replies.

WomanPro

Programmer
Nov 1, 2012
180
GR
Hello!!! I would like to ask if vb.net 2005 supports variables in set of
If yes is it possible to make arithmetical actions between them, for example the common elements.
For example the following set of
arr1 {50, 10, 90, 20, 10, 10, 70, 40, 80}
arr2 {90, 10, 20}
I would like to create another set of that will not include the elements that are equal to 10
I would like to make actions between them, like Section, Union, intersect etc...
Is it possible and how? Could somebody give me an example or a tutorial?


Thank you so much in advanced.

 
exactly that I need but in vb.net 2005, not other program languages!!!!!!!!
 
exactly that I need but in vb.net 2005, not other program languages!!!!!!!
Why? Do you plan to rewrite the entire library. If not it is OOP just use it, you do not need to know how the watch works only how to use it. Add the project to your solution and use the classes. Works fine for me in VB
 
this method doesn't exist, I can't find it anywhere, I don't know how to use it.
 
I am looking for something like that

' Create two integer arrays.
Dim id1() As Integer = {44, 26, 92, 30, 71, 38}
Dim id2() As Integer = {39, 59, 83, 47, 26, 4, 30}

' Find the set intersection of the two arrays.
Dim intersection As IEnumerable(Of Integer) = id1.Intersect(id2)

Dim output As New System.Text.StringBuilder
For Each id As Integer In intersection
output.AppendLine(id)
Next

' Display the output.
MsgBox(output.ToString)

' This code produces the following output:
'
' 26
' 30


It gives error in vb.net 2005
Dim intersection As IEnumerable(Of Integer) = id1.Intersect(id2)
Error 1 'Intersect' is not a member of 'System.Array'.
I can't find anything :(
I am very dissapointed.
 
So playing with the library
Code:
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim mySet1 As New SortedSet(Of String)
        Dim mySet2 As New SortedSet(Of String)
        Dim mySet3 As New SortedSet(Of String)
        mySet1.Add("Dog")
        mySet1.Add("Cat")
        mySet2.Add("Dog")
        mySet2.Add("Mouse")
        mySet3.Add("Mouse")
        mySet1.UnionWith(mySet2)
        For i As Integer = 0 To mySet1.Count - 1
            Me.TextBox1.Text = Me.TextBox1.Text & " " & mySet1(i).ToString
        Next
        Me.TextBox1.Text = Me.TextBox1.Text & Environment.NewLine
        mySet3.IntersectWith(mySet2)
        For i As Integer = 0 To mySet3.Count - 1
            Me.TextBox1.Text = Me.TextBox1.Text & " " & mySet3(i).ToString
        Next
    End Sub
So in my text box I get this.
Cat Dog Mouse 'correct union
Mouse 'correct intersection
 
I am getting error in these statements
Dim mySet1 As New SortedSet(Of String)
Dim mySet2 As New SortedSet(Of String)
Dim mySet3 As New SortedSet(Of String)

Error 2 Type 'SortedSet' is not defined. C:\Documents and Settings\Neraidopetalouda\Τα έγγραφά μου\Visual Studio 2005\Projects\collections\collections\Form1.vb 31 27 collections

Why does this happen??? What library do you use? And with which statement? I am using Imports System.Collections with no effect
 
As I said I went to Code Project and downloaded the library. Then I added the project iesi.collections.csproj. Now I can use the C# project in my solution and use the classes in vb.
 
I can't even open it!!! It's in another version. Any other suggestions please?
 
I opened in VS Studio 2010 Express. I did notice that all of the files were read only, so I had to select them all and then change the property. The folder does not matter if you bring it in as a reference or project.
 
Which version of the DotNet framework are you using?

3.5 is the minimum required for the MSDN example and that appears to do exactly what you want.
 
After including system.core
with :
Imports System.Linq
Imports System.Linq.Enumerable

and Dim intersection As IEnumerable(Of Integer)

intersection = Intersect(Of Integer)(id1, id2)

instead of Dim intersection As IEnumerable(Of Integer) = id1.Intersect(id2)
it worked my jeasus!!!

I just don't understand Enumarator and IEnumarable even if I read it!!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top