Dim abc(2) As Integer
成都网站制作公司哪家好,找创新互联建站!从网页设计、网站建设、微信开发、APP开发、成都响应式网站建设等网站项目制作,到程序开发,运营维护。创新互联建站于2013年创立到现在10年的时间,我们拥有了丰富的建站经验和运维经验,来保证我们的工作的顺利进行。专注于网站建设就选创新互联建站。
abc = {0, 1, 2}
'或者
Dim abcd() As Integer
ReDim abcd(9)
For i As Integer = 0 To abcd.Length - 1
abcd(i) = i
Next
也可声明为字符串数组
Dim x(8, 8)
Dim a As Integer
Dim b As Integer
b = 0
For i = 0 To 8
For j = 0 To 8
If b = 3 Then
b = 1
a = a + 1
Else
b = b + 1
End If
x(i, j) = aNext
Next
for i =0 to ...
for j =0 to ...
keyarray(i,j)=
next
next
双重循环,赋值和读取一样
当然可以的,需要System.Runtime.InteropServices 命名空间中的 Marshal 类
Imports System.Runtime.InteropServices '这里一定要有
Public Class Form1
Public Structure m_Point
Dim x As Integer
Dim y As Integer
End Structure
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim i As Integer = 50
Dim ai() As Integer = {1, 2, 3, 4, 5}
Dim pi As IntPtr = GCHandle.Alloc(i, GCHandleType.Pinned).AddrOfPinnedObject() '取得整形变量的指针
Dim pai As IntPtr = GCHandle.Alloc(ai, GCHandleType.Pinned).AddrOfPinnedObject() '取得整形数组首地址指针
MsgBox(Marshal.ReadInt32(pi, 0)) '读回整形变量指针指向的值
MsgBox(Marshal.ReadInt32(pai, 0 * 4)) '读回数组的第一个元素
MsgBox(Marshal.ReadInt32(pai, 1 * 4)) '读回数组的第二个元素
MsgBox(Marshal.ReadInt32(pai, 2 * 4)) '读回数组的第三个元素
'-----下面是结构--------------------------
Dim m_p As New m_Point
m_p.x = 100
m_p.y = 50
Dim pm_p As IntPtr = GCHandle.Alloc(m_p, GCHandleType.Pinned).AddrOfPinnedObject() '取得结构首地址指针
MsgBox(Marshal.ReadInt32(pm_p, 0 * 4)) '读回结构的第一个值
MsgBox(Marshal.ReadInt32(pm_p, 1 * 4)) '读回结构的第二个值
End Sub
End Class