blob: b6e2b6eebc3aaae9bb053ea0b61787dbd5ce5e73 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
Attribute VB_Name = "ModTask_02"
Option Explicit
Function IsPalindromeNum(ByVal strNumCheck As String) As Boolean
IsPalindromeNum = False
If strNumCheck = StrReverse(strNumCheck) Then
IsPalindromeNum = True
End If
End Function
Sub Task_02()
'' Credit
'' https://datagenetics.com/blog/october12015/index.html
Const nInput As Integer = 56 '' Example 1
'' Const nInput As Integer = 57 '' Example 2
'' Const nInput As Integer = 59 '' Example 3
Const nMaxLoop As Integer = 500
Dim strMsg As String, strTemp As String
Dim nLoop As Integer
strTemp = CStr(nInput)
strMsg = "1"
For nLoop = 1 To nMaxLoop
If Val(strTemp) > 10000000 Then
Exit For
End If
If IsPalindromeNum(strTemp) Then
strMsg = "0"
Exit For
End If
strTemp = CStr(Val(strTemp) + Val(StrReverse(strTemp)))
Next nLoop
MsgBox strMsg, vbOKOnly, strMyTitle
End Sub
|