改成下面這樣就OK了:
成都創(chuàng)新互聯(lián)公司主營(yíng)華鎣網(wǎng)站建設(shè)的網(wǎng)絡(luò)公司,主營(yíng)網(wǎng)站建設(shè)方案,成都app軟件開(kāi)發(fā),華鎣h5小程序定制開(kāi)發(fā)搭建,華鎣網(wǎng)站營(yíng)銷(xiāo)推廣歡迎華鎣等地區(qū)企業(yè)咨詢
關(guān)鍵的代碼如下
Option Explicit
Public nstep As Integer
public pe()
Public Sub Form_Load()
'省略其它代碼
End Sub
Function Inputss()
Input #1, nstep, dt 'nstep表示時(shí)間階步的數(shù)量,dt表示時(shí)間步長(zhǎng)
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
下面這段代碼完成,在窗體上用語(yǔ)句添加2個(gè) GroupBox控件,且在每個(gè)GroupBox控件中添加4個(gè) RadioButton 控件。
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim i As Integer
'添加2個(gè)GroupBox
Dim MyGroupBox(2) As GroupBox
For i = 1 To 2
'將一個(gè)GroupBox控件加入到Form上
MyGroupBox(i) = New GroupBox
Me.Controls.Add(MyGroupBox(i))
'設(shè)置該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
'每個(gè)GroupBox中添加4個(gè)單選按鈕
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)
'設(shè)置該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)
'設(shè)置該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
ReDim 語(yǔ)句支持這樣的語(yǔ)法,它與固定數(shù)組中使用的語(yǔ)法相同。對(duì)于每一維數(shù),每個(gè) ReDim 語(yǔ)句都能改變?cè)財(cái)?shù)目以及上下界。但是,數(shù)組的維數(shù)不能改變。
ReDim DynArray (4 to 12)
例如,用第一次聲明在模塊級(jí)所建立的動(dòng)態(tài)數(shù)組 Matrix1:
Dim Matrix1 () As Integer
然后,在過(guò)程中給數(shù)組分配空間:
Sub CalcValuesNow ()
.
.
.
ReDim Matrix1 (19, 29)
End Sub
這里的 ReDim 語(yǔ)句給 Matrix 分配一個(gè) 20 × 30 的整數(shù)矩陣(元素總大小為 600)。
for i =0 to ...
for j =0 to ...
keyarray(i,j)=
next
next
雙重循環(huán),賦值和讀取一樣