From the course: Visual Basic Essential Training

Unlock this course with a free trial

Join today to access over 24,500 courses taught by industry experts.

Add code to functions

Add code to functions

- [Instructor] Returning zero from these functions satisfies the compiler, but we need the real code to get the random number. So I'll erase this return zero and the first thing I'll do is, I'll declare an instance of the random number generator. This is the random number generator that is part of .NET. And then I'll declare a variable that can hold the results, I'll call that candidate. I'll make that an integer. Then I will get a random number. So to do that, I'll say candidate is equal to the random generator. And here you can see the methods for returning values. So I can get a byte, I can get a double, I can get an n64, I can get a single and I just call next, I'll get back an integer. And then I can provide parameters here. With no parameters, I'll get a non-negative random number. I can also specify that I want a max value or I can also specify that I want a min and a max value. So I can specify a range. What I want to do, is specify the max value and I'll make that 201. At…

Contents