vb题目?

2024-11-23 13:23:33
推荐回答(2个)
回答1:

Private Sub Command1_Click()

    Dim ins, t, outs As String

    ins = Val(Text1.Text)

    For i = Len(ins) To 1 Step -1

        t = Mid(ins, i, 1)

        outs = outs & t

    Next

    If ins = outs Then

        Label1.Caption = ins & "是回文"

    Else

        Label1.Caption = ins & "不是回文"

    End If

End Sub


回答2:

Private Sub Command1_Click()
If Text1.Text = "" Or Val(Text1.Text) <= 0 Or Not IsNumeric(Text1.Text) Or Len(Text1.Text) <> 5 Then
MsgBox "请输入大于零的五位正整数!", vbOKOnly + vbExclamation, "系统提示"
Text1.SetFocus
Exit Sub
End If
If StrReverse(Text1.Text) = Text1.Text Then
Label1.Caption = Text1.Text & "是回文"
Else
Label1.Caption = Text1.Text & "不是回文"
End If
End Sub