Find Code:
All Words
Any of the Words
Exact Phrase
Home
:
Code
:
Forums
:
Submit
:
Mailing List
:
About
:
Contact
Code
All
VB.NET
ASP.NET
C#
VB Classic
ASP Classic
Snippets
Popular
Resources
Submit Code
Forums
Articles
Tips
Links
Books
Contest
Link to us
Even or Odd
Author:
Funkytee
E-mail:
Click to e-mail author
Submitted:
9/28/2010
Version:
VB 2008
Compatibility:
VB 2008, VB 2010
Category:
Forms
Views:
28325
This is a way I found to be simple to test for Even and Odd numbers using the Mod operator.
Declarations:
'none
Code:
Public Class Checkif_EVENorODD Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim Mynumber As Integer Dim isEven As Boolean Mynumber = CInt(InputBox("Enter a number to see if it's an Even or an Odd number")) 'Use the scientific calculator on ur pc to check how mod works (^_^) If Mynumber Mod 2 = 0 Then isEven = True MsgBox("The number " & " " & Mynumber & " an even number") Else MsgBox(Mynumber & " " & "Is an Odd number") End If
Home
|
Forums
|
Submit
|
Books
|
Mailing List
|
Advertising
|
About
|
Contact
© 2024 A1VBCode. All rights reserved.
Legal disclaimer & terms of use
Privacy statement