Home All Groups Group Topic Archive Search About

DLL and form updating problem

Author
6 Apr 2006 4:41 PM
Martin Racette
Hi,

I tried the first part of the suggested code below (in a test program first),
and all I get is an error telling me that
"System.Windows.Forms.ToolStripStatusLabel" is not define and the same for
"System.Windows.Form.Listbox"

With that DLL I'm trying to fill a listbox with many filename from a directory,
I tried the code before in the main window code, but when I try it from a DLL, I
can not get the program to run

The declaration and call for the DLL is as follow
Dim dll as New Library
dll.getfile(ToolStripStatusLabel, FileList_VIew)

In the DLL
Public Class Library
    Public Sub getfile(ByVal mylabel as
System.Windows.Forms.ToolStripStatusLabel, ByVal FileList_View as
System.Windows.Forms.Listbox)
        'the processing code
        myLabel.text = i & " files were found ! "
    end sub
end class

What do I DO wrong here

Thank you in advance
Martin
____________________________
>
Martin,

A couple of options:

1. Pass the controls into the class in the dll, either as properties of the
class or as arguments to a method. For example:

Public Class MyClass1

    Public Sub DoSomething(ByVal myLabel As System.Windows.Forms.Label)

        For i As Integer = 1 To 10
            '
            'Processing
            '
            'Display something in the label
            myLabel.Text = i.ToString
            myLabel.Refresh()
        Next

    End Sub
End Class

Then on a form, call the method and pass it some control, in this case a
label:

        Dim mc1 As New MyClassLibrary.MyClass1

        mc1.DoSomething(Label1)

2. In the class in the dll, raise an event. Handle the event on a form. For
example:

Public Class MyClass2

    Public Event DidSomething(ByVal SomeValue As Integer)

    Public Sub DoSomething()

        For i As Integer = 1 To 10
            '
            'Processing
            '
            'Raise an event
            RaiseEvent DidSomething(i)
        Next

    End Sub
End Class

On a form:

    Private WithEvents mc2 As New MyClassLibrary2.MyClass2

    Private Sub mc2_DidSomething(ByVal SomeValue As Integer) Handles
mc2.DidSomething

        Label1.Text = SomeValue.ToString
        Label1.Refresh()

    End Sub

Then call the method and let the event handler update the label:

        mc2.DoSomething()

Kerry Moorman




Show quoteHide quote
"Martin Racette" wrote:

> Hi,
>
> I recently installed that programing environment, and I'm wondering how to do
> some of the things
>
>  I created a program that renames, moves, and copies file, most of the routine
> are located in a DLL file that I created along with the main program,
> everything
> work fine, but I can not get the routine running in the DLL to update a
> progress
> bar and a label field that I would like the name of the file being processed
> to
> appear
>
> I checked in the help that comes with Visual Basic 2005 Express, but I can not
> find how to do this
>
> Any help would be appreciated
> --
> Thank you in Advance
>
> Merci a l'Avance
>
> Martin
>
>
>

--
Thank you in Advance

Merci a l'Avance

Martin

Author
6 Apr 2006 6:11 PM
Kerry Moorman
Martin,

You need to add a reference to System.Windows.Forms.

In VS2003 you can do that by clicking the Add Reference menu item from the
Project menu, or by right-clicking References from the Solution Explorer
window.

Kerry Moorman


Show quoteHide quote
"Martin Racette" wrote:

> Hi,
>
> I tried the first part of the suggested code below (in a test program first),
> and all I get is an error telling me that
> "System.Windows.Forms.ToolStripStatusLabel" is not define and the same for
> "System.Windows.Form.Listbox"
>
> With that DLL I'm trying to fill a listbox with many filename from a directory,
> I tried the code before in the main window code, but when I try it from a DLL, I
> can not get the program to run
>
> The declaration and call for the DLL is as follow
> Dim dll as New Library
> dll.getfile(ToolStripStatusLabel, FileList_VIew)
>
> In the DLL
> Public Class Library
>     Public Sub getfile(ByVal mylabel as
> System.Windows.Forms.ToolStripStatusLabel, ByVal FileList_View as
> System.Windows.Forms.Listbox)
>         'the processing code
>         myLabel.text = i & " files were found ! "
>     end sub
> end class
>
> What do I DO wrong here
>
> Thank you in advance
> Martin
> ____________________________
> >
> Martin,
>
> A couple of options:
>
> 1. Pass the controls into the class in the dll, either as properties of the
> class or as arguments to a method. For example:
>
> Public Class MyClass1
>
>     Public Sub DoSomething(ByVal myLabel As System.Windows.Forms.Label)
>
>         For i As Integer = 1 To 10
>             '
>             'Processing
>             '
>             'Display something in the label
>             myLabel.Text = i.ToString
>             myLabel.Refresh()
>         Next
>
>     End Sub
> End Class
>
> Then on a form, call the method and pass it some control, in this case a
> label:
>
>         Dim mc1 As New MyClassLibrary.MyClass1
>
>         mc1.DoSomething(Label1)
>
> 2. In the class in the dll, raise an event. Handle the event on a form. For
> example:
>
> Public Class MyClass2
>
>     Public Event DidSomething(ByVal SomeValue As Integer)
>
>     Public Sub DoSomething()
>
>         For i As Integer = 1 To 10
>             '
>             'Processing
>             '
>             'Raise an event
>             RaiseEvent DidSomething(i)
>         Next
>
>     End Sub
> End Class
>
> On a form:
>
>     Private WithEvents mc2 As New MyClassLibrary2.MyClass2
>
>     Private Sub mc2_DidSomething(ByVal SomeValue As Integer) Handles
> mc2.DidSomething
>
>         Label1.Text = SomeValue.ToString
>         Label1.Refresh()
>
>     End Sub
>
> Then call the method and let the event handler update the label:
>
>         mc2.DoSomething()
>
> Kerry Moorman
>
>
>
>
> "Martin Racette" wrote:
>
> > Hi,
> >
> > I recently installed that programing environment, and I'm wondering how to do
> > some of the things
> >
> >  I created a program that renames, moves, and copies file, most of the routine
> > are located in a DLL file that I created along with the main program,
> > everything
> > work fine, but I can not get the routine running in the DLL to update a
> > progress
> > bar and a label field that I would like the name of the file being processed
> > to
> > appear
> >
> > I checked in the help that comes with Visual Basic 2005 Express, but I can not
> > find how to do this
> >
> > Any help would be appreciated
> > --
> > Thank you in Advance
> >
> > Merci a l'Avance
> >
> > Martin
> >
> >
> >
>
> --
> Thank you in Advance
>
> Merci a l'Avance
>
> Martin
>
>
>