vb.过程判断是否为回文数。求错误原因。在线等!!

2025-01-05 01:13:54
推荐回答(1个)
回答1:


Private Sub Command1_Click()
Dim i As Integer
Dim a(1000) As Long '删除这一行
Randomize
For i = 1 To 1000
a(i) = (Int(99999 - 10000 + 1) * Rnd) + 10000
List1.AddItem a(i)
Next i
End Sub
这个里边的那行声明数组的语句删除掉

你这个里边的类型,全部依靠VB来转换,很可能出问题的????

你把自定义函数,稍微改一下,如下就可以了:
Private Function huiwenshu(a As Long) As Boolean
Dim c As String, y As String
Dim LinStr As String
LinStr = CStr(a)
huiwenshu = True
For i = 1 To Len(LinStr)
c = Mid(LinStr, i, 1)
y = c & y
Next i
If LinStr = y Then
huiwenshu = False
End If

End Function