0

嗨,我是 VB 新手,使用数组时遇到问题。我的代码是这样的。这是类 FindFactorsObject.vb

Public Sub FindFactors()
    count = 0
    temp = Convert.ToInt32(Math.Sqrt(_x))
    For i As Integer = 1 To temp
        If _x Mod i = 0 Then
            ReDim array(count)
            array(count) = i
            count += 1
        End If
    Next

所以我创建了一个数组并存储了结果。现在我想在 Form.vb 中显示我的数组中的每个值,如果可能的话,有人可以教我如何为每个显示的值设置延迟。非常感谢

4

1 回答 1

0

总是声明你的变量,如果可能的话,它们的确切类型,你认为他们会处理的。当您说“现在我想在 Form.vb 中显示我的数组中的每个值”时,我从字面上理解:在表单中,我们将在您的表单上打印它们

Public Sub FindFactors(_x As Integer)
    Dim temp As Integer = Convert.ToInt32(Math.Sqrt(_x))
    Dim l As New List(Of Integer)
    For i As Integer = 1 To temp
        If _x Mod i = 0 Then
            l.add(i)
        End If
    Next
    Dim pf As New PointF(20, 20)
    For Each i As Integer In l
        creategraphics.drawstring(i.ToString, New font(font.fontFamily, 24), brushes.cadetblue, pf)
        pf = New PointF(pf.X, pf.Y + 30)
    Next
End Sub
于 2012-08-25T00:00:21.473 回答