views:

40

answers:

2

How could I call a module or something else to return data to me after its ran. I don't want to make my form1 code all messy.

Thanks!

Example by what I mean return:

Public Function Test() As String
    Return "Tes34t"
End Function

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    MessageBox.Show(Test)
End Sub
+1  A: 

If Test is in the same class (Form1), then just use

MessageBox.Show(Test())

If it's in module "MyModule", then use

MessageBox.Show(MyModule.Test())
John Saunders
Thanks! This worked :D.
xZerox
Great anwer, guess nobody would think the person asking the question would overlook that. I was thinking he would like a possibility to dynamically call a function, but it was this simple :)
Gertjan
A: 

Possibly Using Generic Collection:

Public Class MyObjectCollection
    Inherits Collection<MyObject>

    Public ReadOnly Property InnerList As List<MyObject>
        Get
            Return CType(List,List<MyObject>Wink
        End Get
    End Property

    Public Sub Sort(ByVal comparer As IComparer)
        InnerList.Sort(comparer)
    End Sub

    Public Class MyObjectCollection
    End Class
End Class
Joe Garrett
@Joe: did you respond to the correct question? What's his question have to do with lists?
John Saunders
Obviously, not ... I was tired and getting a bit punchy.
Joe Garrett