From the course: Visual Basic Essential Training

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Use parameters with procedures

Use parameters with procedures - Visual Basic Tutorial

From the course: Visual Basic Essential Training

Start my 1-month free trial

Use parameters with procedures

- [Instructor] We should consider refactoring the code in these two functions, because it's mostly duplicate code. I think we can pull out some of the sections of this code and put it in separate functions that stand on their own. Along the way, I'll get to show you some of the Visual Studio refactoring tools. So, the first thing is to decide what code we need to refactor, and I'm looking at these first two lines of code, where I declare a random number and then I get a random number. I can pull those out and make a separate function. To do that, I'll select those two lines of code, and then go to the Edit menu, and choose Refactor, Extract Method. Visual Studio pulls the code out, and puts it at the bottom of the screen, you can see on line 23, and then it fixes up the code on line 14, and now it's waiting for me to name this new method. I can just type the new method in, I think I'll call this GetRandomNumber.…

Contents