Private Sub Command1_Click()
Dim x As String, n As Integer, i As Integer
Dim k As Integer, start As Integer
Dim max As Integer
x = Text1.Text: n = Len(x)
max = 0: start = 1
For i = 1 To n
k = n
Do While k > i
IfAnd k - i + 1 > max Then
max = k - i + 1
start=i
End If
Loop
Next i
Label2.Caption =“最长回文字符串为” + Mid(x, start, max)
End Sub
Function isPa(t As String) As Boolean ’判断是不是回文数
Dim i As Integer
For i = 1 To Len(t) \ 2
If Mid(t, i, 1) <> Mid(t, Len(t) - i + 1, 1) Then isPa = False
Next i
End Function