VB判断回文数程序怎么打

判断一个数以下的
2025-01-04 22:53:35
推荐回答(3个)
回答1:

Private Sub Command1_Click()
Dim a, i As Integer, n, s As String
For i = 1 To Val(InputBox("请输入最大数!"))
a = Split(i, vbCrLf)
For Each n In a
s = s & n
If i > 10 And n = StrReverse(n) Then
s = i & "为回文数"
Print s
End If
Next
Next i
End Sub

回答2:

Private Sub Form_Click()
Dim s As String
s = InputBox("请输入一串字符:")
If s = StrReverse(s) Then MsgBox "是回文"
End Sub

回答3:

建一个Text1,Text2,Command1。
Text1,Text2的Multiline都设置为True。
代码如下。

Private Sub Command1_Click()
Text2.Text = ""
Dim a, i As Integer, n, s As String
a = Split(Text1.Text, vbCrLf)
For Each n In a
s = s & n
If n = StrReverse(n) Then s = s & "★"
s = s & vbCrLf
Next
Text2.Text = s
End Sub