0

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
3
  • A slightly off-topic advice: give your form a nicer name. Form1 does not describe anything. Commented Jul 12, 2010 at 6:10
  • @Gertjan: You cannot tell what the name of the Form is from the sample code. The name of the method that handles the form's Load event is "Form1_Load". Commented Jul 12, 2010 at 10:52
  • @AMissico: Yes you can, first of all Visual Studio will create names of events according to the form name plus user is xzerox says: "I don't want to make my form1 code all messy.". Apart from that it is only an advice, good coding begins with clean code. Commented Jul 12, 2010 at 13:37

1 Answer 1

1

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())
Sign up to request clarification or add additional context in comments.

1 Comment

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 :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.