Private Sub Command1_Click()
Dim I As Long, J As Long
Dim X1 As Long, X2 As Long
Dim str As String
Dim Flag As Boolean
str = "从 10000 到 99999 之间的回文数有:" & vbCrLf
For I = 10000 To 99999
Flag = False
For J = 1 To Len(CStr(I))
If Mid(CStr(I), J, 1) <> Mid(CStr(I), Len(CStr(I)) - J + 1, 1) Then
Flag = True
Exit For
End If
Next J
If Flag = False Then str = str & I & " "
Next I
MsgBox str
End Sub
dim str as string
dim i as integer
dim j as integer
dim k as integer
dim l as integer
dim hwdata(899) as integer
l=0
for i=1 to 9
for j=0 to 9
for k=0 to 9
str=trim(str(i)) & trim(str(j)) & trim(str(k)) & trim(str(j)) & trim(str(i))
hwdata(l)=val(str)
l=l+1
next k
next j
next i
hwdata中保存得是所有得回文数据
把这些数的个位,十位。百位,千位,万位分别用变量保存起来,只要对比个位跟万位相等,同时十位跟千位相等的就是了。