sharkyenergy
sharkyenergy

Reputation: 4173

put the code in a different file and then "include" it?

In my vb.net project, there are tons of buttons and various items. I would like to keep this code in the form1.vb file. One specific button tough, executes a very long piece of code. What I would like to do is put this code in a different file and then "include" it inside the button. I was thinking of a class, but it looses the connection to all the global variables and the stuff needed for that code. I do not really NEED to put this in a different file, its just something that sits there, that i will not look at again and being so long its in the way. Is there a way to put this in a different file and then include it sort of like it is done in php? I am on visual studio 2015 community edition

Upvotes: 0

Views: 741

Answers (1)

Jesse Hufstetler
Jesse Hufstetler

Reputation: 718

Use a partial class such as this:

Partial Public Class Form1
    Private Sub doStuff()
        Windows.Forms.MessageBox.Show("This is where your long code should go")
    End Sub
End Class

Partial classes add more functionality to your class but they can be contained in a seperate file.

http://visualbasic.about.com/od/usingvbnet/a/partclses.htm

Upvotes: 2

Related Questions