fork download
  1. Imports System
  2.  
  3. Public Class Test
  4. Public Shared Sub Main()
  5. ' (一)
  6. Dim intArray(19, 29) As Integer
  7. ' ()
  8. ReDim intArray(19, 39)
  9. setArray(intArray)
  10. ' (三)
  11. Console.WriteLine("答案(三)" & vbCrLf & countNegativeValue(intArray))
  12. ' ()
  13. Dim A(5) As Integer
  14. randomNumber(A)
  15. Console.ReadKey()
  16.  
  17. End Sub
  18. ' (三)
  19. ' 計算二微陣列裡有多少負數
  20. Function countNegativeValue(ByRef x As Array) As Integer
  21. Dim count As Integer
  22. count = 0
  23. For i = x.GetLowerBound(0) To x.GetUpperBound(0)
  24. For j = x.GetLowerBound(1) To x.GetUpperBound(1)
  25. If x(i, j) < 0 Then
  26. count += 1
  27. End If
  28. Next j
  29. Next i
  30. Return count
  31. End Function
  32. ' (四)
  33. Sub randomNumber(ByRef A As Array)
  34. For i = 0 To A.GetUpperBound(0)
  35. A.SetValue(CInt(Int((49 * Rnd()) + 1)), i)
  36. Next
  37. Console.WriteLine("答案(四)")
  38. For i = 0 To 5
  39. Console.Write(A(i) & ",")
  40. Next
  41. End Sub
  42. ' 初始化陣列值
  43. Sub setArray(ByRef x As Array)
  44. 'Console.WriteLine(x.GetUpperBound(0))
  45. 'Console.WriteLine(x.GetUpperBound(1))
  46.  
  47. For i = x.GetLowerBound(0) To x.GetUpperBound(0)
  48. For j = x.GetLowerBound(1) To x.GetUpperBound(1)
  49. If i = 0 Then
  50. ' 第一列設為-1
  51. x.SetValue(-1, i, j)
  52. End If
  53. Next j
  54. Next i
  55.  
  56. End Sub
  57. End Class
  58.  
  59.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Visual Basic.Net Compiler version 0.0.0.5943 (Mono 3.8 - tarball)
Copyright (C) 2004-2010 Rolf Bjarne Kvinge. All rights reserved.

/home/fMqD4o/prog.vb (9,18) : error VBNC30369: Cannot refer to an instance member of a class from within a shared method or shared member initializer without an explicit instance of the class.
/home/fMqD4o/prog.vb (11,64) : error VBNC30369: Cannot refer to an instance member of a class from within a shared method or shared member initializer without an explicit instance of the class.
/home/fMqD4o/prog.vb (14,22) : error VBNC30369: Cannot refer to an instance member of a class from within a shared method or shared member initializer without an explicit instance of the class.
/home/fMqD4o/prog.vb (23,16) : error VBNC30451: 'i' is not declared. It may be inaccessible due to its protection level.
/home/fMqD4o/prog.vb (34,16) : error VBNC30451: 'i' is not declared. It may be inaccessible due to its protection level.
/home/fMqD4o/prog.vb (38,16) : error VBNC30451: 'i' is not declared. It may be inaccessible due to its protection level.
/home/fMqD4o/prog.vb (47,16) : error VBNC30451: 'i' is not declared. It may be inaccessible due to its protection level.
There were 7 errors and 0 warnings.
Compilation took 00:00:00.9706860
stdout
Standard output is empty