vb 编程问题
求回文数 编码如下 哪里错了 Public Class Form1 Function ishui(ByVal x As Integer) As Boolean ishui = True Dim i As Integer For i = 1 To Len(x) / 2 If Mid(x, i, 1) <> Mid(x, Len(x) + 1 - i, 1) Then ishui = False Exit For End If Next End Function Private Sub Label2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label2.Click End Sub Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim n As Integer n = TextBox1.Text If ishui(n) = True Then Label3.Text &= n & "★" + vbCrLf
答案:Public Class Form1 Function ishui(ByVal x As Integer) As Boolean ishui = True
Dim i As Integer
For i = 1 To Len(x) div 2
If Mid(x, i, 1) <> Mid(x, Len(x) + 1 - i, 1) Then
ishui = False
Exit For
End If
Next
End Function
Private Sub Label2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Label2.Click
End Sub
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button1.Click
Dim n As Integer
n = TextBox1.Text
If ishui(n) = True Then Label3.Text &= n & "★" + vbCrLf
end sub
上一个:VB编程问题
下一个:VB 编程求助