开发者

vb express 2010 populating array

开发者 https://www.devze.com 2023-01-19 19:37 出处:网络
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?\")

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

精彩评论

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