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.

Add code to functions

Add code to functions - Visual Basic Tutorial

From the course: Visual Basic Essential Training

Start my 1-month free trial

Add code to functions

- [Instructor] Returning zero from these functions is not correct, let's fix the code. I've reverted the code back from the class to the module and I've removed the print document sub because we don't need it for the rest of the chapter. First step is to get the random number generator from .NET. To do that, I'll instantiate the random class and I'll store reference to that in this RAN variable. Then I'll call the random generator and get a value, I'll call that one candidate. So I call the next method which returns an integer. And then I'll specify the maximum value that I want. So max value equal to 201. I'm using a name parameter here, we'll see how to do parameters soon in this chapter. I'll get a number between zero and 201. Then I'll test if it's odd or even. To do that I'm using the Mod operator that divides candidate by two and returns the remainder. So if I get a remainder of one, I know it's an odd number.…

Contents