VB.NET 二维数组 引用其中的一维
OPCItemIDsData(j,其中一维)即可。
创新互联长期为数千家客户提供的网站建设服务,团队从业经验10年,关注不同地域、不同群体,并针对不同对象提供差异化的产品和服务;打造开放共赢平台,与合作伙伴共同营造健康的互联网生态环境。为临汾企业提供专业的网站设计、成都网站制作,临汾网站改版等技术服务。拥有十余年丰富建站经验和众多成功案例,为您定制开发。
如果前面方法有规定,不能用二维数组的格式,那么你可以自己定义一个一维数组,将二维数组的某一维度的全部数值赋值给这个数组,在引用这个数组:
dim OPCItemIDsDataBuf(x) as ...
for i = 1 to x
OPCItemIDsDataBuf(j)=OPCItemIDsData(j,其中一维)
next i
其中x是数组的最大下标
VB.NET 二维数组问题
根据你的语句,上下标是确定的,所以定义语句修改为:
Dim ary(UBound(temp), 1) As String '声明二维数组
VB.net中,请问如何将二维数组的数值显示在listview控件中?
将二位数组转成DataTable,网上找的不知道成不成
public static DataTable ConvertToDataTable(string[,] arr)
{
DataTable dataSouce = new DataTable();
for (int i = 0; i arr.GetLength(1); i++)
{
DataColumn newColumn = new DataColumn(i.ToString(), arr[0, 0].GetType());
dataSouce.Columns.Add(newColumn);
}
for (int i = 0; i arr.GetLength(0); i++)
{
DataRow newRow = dataSouce.NewRow();
for (int j = 0; j arr.GetLength(1); j++)
{
newRow[j.ToString()] = arr[i, j];
}
dataSouce.Rows.Add(newRow);
}
return dataSouce;
}
VB.NET 2维数组排序排序和赋值问题
窗体上添加3个标签,1个按钮,在按钮的单击事件里写代码,如下:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim a(,) As Integer = {{5, 6}, {1, 3}, {8, 9}, {72, 1}, {63, 4}}
Dim Temp As Integer
Dim i As Integer
Dim j As Integer
Dim x As Integer
Dim y As Integer
'显示排序前的数据
Label1.Text = "排序前数据:" vbCrLf
For i = 0 To 4
Label1.Text = Label1.Text a(i, 0) " " a(i, 1) vbCrLf
Next
For i = 0 To 3
For j = i + 1 To 4
If a(i, 0) a(j, 0) Then
Temp = a(i, 0)
a(i, 0) = a(j, 0)
a(j, 0) = Temp
Temp = a(i, 1)
a(i, 1) = a(j, 1)
a(j, 1) = Temp
End If
Next
Next
'显示排序前的数据
Label2.Text = "排序后数据:" vbCrLf
For i = 0 To 4
Label2.Text = Label2.Text a(i, 0) " " a(i, 1) vbCrLf
Next
'把第3行元素赋予X,Y
x = a(2, 0)
y = a(2, 1)
'输出X,Y
Label3.Text = "X=" x vbCrLf "Y=" y
End Sub
VB.net中如何求出2维数组,每个维度上的值得个数
每行的数字个数不同,你说的这是不规则数组,解决方案如下:
Dim b As String = ""
Dim a As Integer()() = New Integer(9)() {}
a(0) = New Integer() {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
a(1) = New Integer() {0, 3, 4, 5}
a(2) = New Integer() {0, 4, 5, 6, 7}
a(3) = New Integer() {0, 6, 5, 8, 9, 1}
a(4) = New Integer() {0, 2, 5, 1, 7}
a(5) = New Integer() {0, 4, 2, 6, 7, 3}
a(6) = New Integer() {0, 4, 5, 3, 2}
a(7) = New Integer() {0, 4, 1, 6, 2, 8, 5, 3}
a(8) = New Integer() {0, 4, 9, 6, 3, 5, 7}
a(9) = New Integer() {0, 1, 5, 9, 7, 6, 2, 4, 3, 8}
For i As Integer = 0 To a.GetUpperBound(0)
b = "第" i + 1 "行有" a(i).GetUpperBound(0) + 1 "个数" vbCrLf
Next
MessageBox.Show(b)
网页标题:vb.net2维数组 vb二维数组元素个数
标题路径:http://lswzjz.com/article/higeoe.html