你的i = Len(Str(a))會出問題。
If i > 1 Then
Return True
End If
這個返回在if內部,當條件不滿足將導致函式無返回。
以下程式碼僅供參考:
Function IsH(ByVal a As Long) As Boolean
Dim i As Long, j As Long, t As String
t = a.ToString
i = t.Length
Select Case i
Case 1
Case 2
If Mid(t, 1, 1) = Mid(t, 2, 1) Then Return True Else Return False
Case 3
If Mid(t, 1, 1) = Mid(t, 3, 1) Then Return True Else Return False
Case Else
For j = 1 To i \ 2
If Mid(t, j, 1) <> Mid(t, i - j + 1, 1) Then Return False
Next j
End Select
End Function
你的i = Len(Str(a))會出問題。
If i > 1 Then
Return True
End If
這個返回在if內部,當條件不滿足將導致函式無返回。
以下程式碼僅供參考:
Function IsH(ByVal a As Long) As Boolean
Dim i As Long, j As Long, t As String
t = a.ToString
i = t.Length
Select Case i
Case 1
Return True
Case 2
If Mid(t, 1, 1) = Mid(t, 2, 1) Then Return True Else Return False
Case 3
If Mid(t, 1, 1) = Mid(t, 3, 1) Then Return True Else Return False
Case Else
For j = 1 To i \ 2
If Mid(t, j, 1) <> Mid(t, i - j + 1, 1) Then Return False
Next j
End Select
Return True
End Function