Advertisement
n0s3c

MathUtility.vb

Nov 28th, 2019
365
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Namespace MathUtility
  2.     'Module for identifying palindromic numbers.
  3.    Public Module Palindrome
  4.         'Function for reversing string entries.
  5.        Public Function Reverse(ByVal value As String) As String
  6.             'Returns the reversed string
  7.            Return StrReverse(value)
  8.         End Function
  9.         'Function for converting a numeric value to String.
  10.        Public Function IntToString(ByVal value As Long) As String
  11.             'Returns a string of the numeric value.
  12.            Return CStr(value)
  13.         End Function
  14.         'Function for checking if the number is palindromic.
  15.        Public Function IsPalindrome(value As Long) As Boolean
  16.             'Selects the valid case.
  17.            Select Case True
  18.                 'Case: if the reversed number = user input.
  19.                Case value = Reverse(IntToString(value))
  20.                     'Returns true.
  21.                    Return True
  22.                     'Case: if the reversed number ≠ user input.
  23.                Case Else
  24.                     'Returns false.
  25.                    Return False
  26.             End Select
  27.         End Function
  28.     End Module
  29. End Namespace
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement