如何让一个arraylist在VB.NET中的所有子系统中工作?

时间:2017-01-18 16:40:57

标签: vb.net

我试图让一个arraylist在所有潜艇上工作。我一直有问题,系统不会识别arraylist名称,并希望我为它生成一个新的存根或属性。我正在尝试编写一个程序,它将获取用户输入的数字并按降序和升序对它们进行排序。感谢您提供的任何帮助,我对编程很新,并且不了解所有内容。

Module Module1
'This is a program written by Ben Sampley in order to print user defined numbers in ascending and descending orders
Public Sub Main()
    Dim n1, n2, n3, n4, n5, n6, n7, n8, n9, n10 As Integer
    Dim title As String = "Input Number"
    n1 = InputBox("Please Enter A Whole Number Between 1 And 100", title, "0") 'Asks for user input and assigns a variable to the input
    n2 = InputBox("Please Enter A Whole Number Between 1 And 100", title, "0") 'Asks for user input and assigns a variable to the input
    n3 = InputBox("Please Enter A Whole Number Between 1 And 100", title, "0") 'Asks for user input and assigns a variable to the input
    n4 = InputBox("Please Enter A Whole Number Between 1 And 100", title, "0") 'Asks for user input and assigns a variable to the input
    n5 = InputBox("Please Enter A Whole Number Between 1 And 100", title, "0") 'Asks for user input and assigns a variable to the input
    n6 = InputBox("Please Enter A Whole Number Between 1 And 100", title, "0") 'Asks for user input and assigns a variable to the input
    n7 = InputBox("Please Enter A Whole Number Between 1 And 100", title, "0") 'Asks for user input and assigns a variable to the input
    n8 = InputBox("Please Enter A Whole Number Between 1 And 100", title, "0") 'Asks for user input and assigns a variable to the input
    n9 = InputBox("Please Enter A Whole Number Between 1 And 100", title, "0") 'Asks for user input and assigns a variable to the input
    n10 = InputBox("Please Enter A Whole Number Between 1 And 100", title, "0") 'Asks for user input and assigns a variable to the input

    Dim numbers As ArrayList = New ArrayList 'new arraylist called numbers
    numbers.add(n1) 'Adds to arraylist
    numbers.add(n2) 'Adds to arraylist
    numbers.add(n3) 'Adds to arraylist
    numbers.add(n4) 'Adds to arraylist
    numbers.add(n5) 'Adds to arraylist
    numbers.add(n6) 'Adds to arraylist
    numbers.add(n7) 'Adds to arraylist
    numbers.add(n8) 'Adds to arraylist
    numbers.add(n9) 'Adds to arraylist
    numbers.add(n10) 'Adds to arraylist

    Dim numasc As Threading.Thread = New Threading.Thread(AddressOf ascending) 'sets the number ascending
    numasc.Start() 'starts thread
    Dim numdesc As Threading.Thread = New Threading.Thread(AddressOf descending) 'sets the numbers descending
    numdesc.Start() 'starts thread
End Sub
Public Sub ascending()
    numbers.sort()
    console.writeline("The numbers in sorted ascending order are")
    Print(numbers)
End Sub
Public Sub descending()
    numbers.sort()
    numbers.reverse()
    console.writeline("The numbers in sorted descending order are")
    Print(numbers)
End Sub

结束模块

0 个答案:

没有答案