vbnet动态二维数据 vbnet二维数组
VB动态二维数组的声明与调用
改成下面这样就OK了:
成都创新互联公司主营华蓥网站建设的网络公司,主营网站建设方案,成都app软件开发,华蓥h5小程序定制开发搭建,华蓥网站营销推广欢迎华蓥等地区企业咨询
关键的代码如下
Option Explicit
Public nstep As Integer
public pe()
Public Sub Form_Load()
'省略其它代码
End Sub
Function Inputss()
Input #1, nstep, dt 'nstep表示时间阶步的数量,dt表示时间步长
redim pe(nstep) As Single
For i = 1 To nstep
Input #1, r(i), pe(i), qpbs(i)
Next i
Close #1
For it = 1 To nstep
q(it) = 0
Next it
End Function
Function topmod()
For it = 1 To nstep
Dim qof As Single, quz As Single
ep = pe(it)
p = r(it)
'省略其它代码
next it
End Function
VB.NET 用二维数组的方式动态加控制 例如在窗体上动态添加GroupBox,然后再在GroupBox里动态添加控件
下面这段代码完成,在窗体上用语句添加2个 GroupBox控件,且在每个GroupBox控件中添加4个 RadioButton 控件。
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim i As Integer
'添加2个GroupBox
Dim MyGroupBox(2) As GroupBox
For i = 1 To 2
'将一个GroupBox控件加入到Form上
MyGroupBox(i) = New GroupBox
Me.Controls.Add(MyGroupBox(i))
'设置该GroupBox控件的属性
MyGroupBox(i).Height = 240
MyGroupBox(i).Width = 600
MyGroupBox(i).Top = (i - 1) * (240 + 20) + 20
MyGroupBox(i).Left = 20
'修改新加入控件的Text值
MyGroupBox(i).Text = "GroupBox" CStr(i)
Next
'每个GroupBox中添加4个单选按钮
Dim MyRadioButton1(4) As RadioButton
Dim MyRadioButton2(4) As RadioButton
For i = 1 To 4
MyRadioButton1(i) = New RadioButton
Me.Controls.Add(MyRadioButton1(i))
MyRadioButton1(i).Parent = MyGroupBox(1)
'设置该GroupBox控件的属性
MyRadioButton1(i).Height = 20
MyRadioButton1(i).Width = 120
MyRadioButton1(i).Top = (i - 1) * (20 + 20) + 40
MyRadioButton1(i).Left = 20
'修改新加入控件的Text值
MyRadioButton1(i).Text = "RadioButton1_" CStr(i)
Next
For i = 1 To 4
MyRadioButton2(i) = New RadioButton
Me.Controls.Add(MyRadioButton2(i))
MyRadioButton2(i).Parent = MyGroupBox(2)
'设置该GroupBox控件的属性
MyRadioButton2(i).Height = 20
MyRadioButton2(i).Width = 120
MyRadioButton2(i).Top = (i - 1) * (20 + 20) + 40
MyRadioButton2(i).Left = 20
'修改新加入控件的Text值
MyRadioButton2(i).Text = "RadioButton2_" CStr(i)
Next
End Sub
VB 中定义二维动态数组的方法
ReDim 语句支持这样的语法,它与固定数组中使用的语法相同。对于每一维数,每个 ReDim 语句都能改变元素数目以及上下界。但是,数组的维数不能改变。
ReDim DynArray (4 to 12)
例如,用第一次声明在模块级所建立的动态数组 Matrix1:
Dim Matrix1 () As Integer
然后,在过程中给数组分配空间:
Sub CalcValuesNow ()
.
.
.
ReDim Matrix1 (19, 29)
End Sub
这里的 ReDim 语句给 Matrix 分配一个 20 × 30 的整数矩阵(元素总大小为 600)。
VB.NET 动态二维数组如何循环赋值和取值
for i =0 to ...
for j =0 to ...
keyarray(i,j)=
next
next
双重循环,赋值和读取一样
当前名称:vbnet动态二维数据 vbnet二维数组
本文地址:http://azwzsj.com/article/hpshid.html