A. vb如何编程
Option Explicit
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Dim S As String, S1 As String, S2 As String
Dim I As Integer, J As Integer
Dim G As Integer, Hw As Boolean, Find As Boolean
S = Text1.Text
Text1.Text = Text1 + vbCrLf
S1 = S
G = 0
Do While S1 <> ""
Find = False
For I = 1 To Len(S1)
If Mid(S1, I, 1) = " " Or I = Len(S1) Then
Find = True
S2 = Trim(Left(S1, I))
If I = Len(S1) Then S1 = "" Else S1 = Right(S1, Len(S1) - I)
For J = 1 To Len(S2) \ 2
If Mid(S2, J, 1) <> Mid(S2, Len(S2) - J + 1, 1) Then
Hw = False
Exit For
End If
Hw = True
Next
If Hw Then
G = G + 1
Text1.Text = Text1 + " " + S2
End If
End If
If Find Then Exit For
Next
Loop
Text1.Text = Text1.Text + vbCrLf + "共有" + Str(G) + "个回文串"
End If
End Sub
已经运行过了,没问题!即使串与串之间多输入几个空格也不影响查找!