紧急求助VB高手来帮忙!!如图填空

2024-11-27 18:37:20
推荐回答(1个)
回答(1):

Private Sub Command1_Click()
Dim w As Double
Dim j As Long
Dim e As Boolean
If IsNumeric(Text1.Text) Then
w = Val(Text1.Text)
If w > 0 And w = Int(w) Then
e = True
For j = 1 To Len(Trim(w)) / 2 Step 1
If Mid(CStr(w), j, 1) _
<> Mid(CStr(w), Len(Trim(w)) - j + 1, 1) Then
e = False
Exit For
End If
Next j
If e = True Then
Text2.Text = "是回文数"
Else
Text2.Text = "不是回文数"
End If
Else
Text2.Text = "输入的数据是负数或者小数!请输入一个自然数"
End If
Else
Text2.Text = "输入的内容不是一个合法的数值"
End If
End Sub