VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Even or Odd function.

by Jack Jarvis (6 Submissions)
Category: Databases/Data Access/DAO/ADO
Compatability: Visual Basic 3.0
Difficulty: Unknown Difficulty
Originally Published: Fri 18th April 2008
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Even or Odd function.

Rate Even or Odd function.



'Jack Jarvis
Dim W, another As Single
Dim it As String
Dim x As Integer
W = thenumber / 2 ' divide the number by 2
another = Len(W) ' set the length
x = 1
Do
it = Mid(W, x, 1) ' look at each number individually
If it = "." Then GoTo 25 'if it has a decimal then its odd I.E whole number"
x = x + 1 ' move to next letter
On Error GoTo 30 ' if it a single even number then it only has one number so exit function with a value of even
Loop Until x = another ' go until all of the number has been examined
GoTo 30
25
isitevenorodd = "ODD"
Exit Function
30
isitevenorodd = "Even"
End Function

Download this snippet    Add to My Saved Code

Even or Odd function. Comments

No comments have been posted about Even or Odd function.. Why not be the first to post a comment about Even or Odd function..

Post your comment

Subject:
Message:
0/1000 characters