开发者

vb express 2010 populating array

it doesnt like my code:

    Dim n As Integer
    Dim flag As Boolean
    Dim i
    Dim x() As Integer

    n = InputBox("How many numbers do you want to be sorted?")

    For i = 1 T开发者_开发知识库o n - 1 Step 1
        x(i) = InputBox("Please enter a record")
    Next i

I want to put values into x()


You need to use a ReDim to specify the size of x as soon as you know it (ie after your first InputBox):

n = InputBox("How many numbers do you want to be sorted?")
ReDim x(n - 1)

Also, your For loop will be simpler to handle if it's zero based as in:

For i = 0 To n - 1 Step 1
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜