2008年4月19日 星期六

迴文判斷

基本架構練習:


Dim InVal As Long
Dim OutVal As Long
Dim TmpVal As Long
Dim OldVal As Long

Dim i As Integer

Private Sub Form_Activate()
InVal = 1234321
OldVal = InVal

For i = 1 To 10
TmpVal = InVal Mod 10
OutVal = OutVal * 10 + TmpVal
InVal = InVal \ 10
If InVal = 0 Then Exit For

Next i
Print OldVal
Print OutVal
If OldVal = OutVal Then
Print OldVal; "is a palindrome."
Else
Print OldVal; "is not a palindrome."
End If

End Sub

沒有留言: