usingMaths.com
Demonstrating and showing pupils and students one application of Mathematics.







<< PreviousNext >>

Code for Listing Odd Numbers in Visual Basic (VB.Net)



What are Odd Numbers?

Odd numbers are numbers that are not divisible by 2.

They include:

1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, ...

Thankfully, odd numbers complement even numbers. So our code is almost same as the one for even numbers.

Create a new class file; Project, Add Class.
Call it oddNumbers.vb.
Optionally, create a new module file; Project, Add Module.
Call it OddModule.vb.
Type out the adjoining Visual Basic (VB.Net) code for listing odd numbers.



Note: You can simply comment out the previous evenNumbers VB.Net object code from the main class or continue from where it stopped.



Code for Odd Number List with Input in Visual Basic (VB.Net)

For a little more flexibility, let's add an input form.

All we need is a way to ask the user for input.
For this purpose, we'll use the Console.ReadLine() library function.









<< PreviousNext >>