方便新手编写程序,学习visual basic语法。下拉框选择visual basic、windows、控制台,然后选择.NET Framework,因为这个是更新的。
在打开的项目中,键入以下代码:
vbnet
Module Module1
Sub Main()
'Console.WriteLine("hello")
Dim x(2, 2)
x(0, 0) = "Tom"
x(0, 1) = "BMW"
x(0, 2) = "Ford"
x(1, 0) = "Apple"
x(1, 1) = "Orange"
x(1, 2) = "Banana"
x(2, 0) = "Coke"
x(2, 1) = "Pepsi"
x(2, 2) = "Sprite"
For i = 0 To 2
For j = 0 To 2
Console.Write(x(i, j) & " ")
Next
Console.WriteLine()
Next
End Sub
End Module
visual basic使用Console.Write往控制台输出数据,与C#一样。Dim 声明变量,Dim x(2,2)声明二维数组。Module相当于类,Sub Main声明方法,"For i=0 To 2"是循环语句。