最后三句话,提示下标越界,我知道是因为n,m不一定大于1,但是不知道怎么改程序才对,麻烦高手帮忙改下!
PrivateSubform1_load()'逐步回归文件窗体OptionExplicitDimintIAsInteger,intJAsIntegerDimintFile...
Private Sub form1_load()
'逐步回归文件窗体
Option Explicit
Dim intI As Integer, intJ As Integer
Dim intFileNumber As Integer '文件号
Dim strData As String '临时保存数据
Dim blnTitle As Boolean '是否有标题
Dim blnRowLabel As Boolean '是否有行标
Dim blnColLabel As Boolean '是否有列标
Dim m1 As Integer
Dim n As Integer
Dim m As Integer
Dim b() As String
Private Sub Form_Load()
Form1.Show
File1.Pattern = "*.*" '只显示数据文件
End Sub
'选择目录
Private Sub Dir1_Change()
File1.Path = Dir1.Path
End Sub
'选择驱动器
Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive
End Sub
'确定数据文件
Private Sub File1_Click()
txtFile.Text = Dir1.Path & "\" & File1.FileName
End Sub
'确定,给出文件名和行数、列数后单击
Private Sub cmdOK_Click()
strFileName = txtFile.Text '文件名
intFileNumber = FreeFile '取得空闲的文件号码
Open strFileName For Input As intFileNumber
Input #intFileNumber, strData '读列数
intCol = Val(strData) '取得列数
If intCol >= 2 Then
For intI = 2 To intCol '空转,读*****
Input #intFileNumber, strData
Next intI
End If
Do Until EOF(1)
Input #intFileNumber, strData '读行数
intRow = Val(strData) '取得行数
If intCol >= 2 Then
For intI = 2 To intCol '空转,读*****
Input #intFileNumber, strData
Next intI
End If
Loop
Close intFileNumbe
n = intRow: m1 = intCol: m = m1 - 1
'重新定义变量数组
ReDim xy(1 To n, 1 To m1)
'保存回归系数组和工作单元
ReDim b(m)
'重新定义t检验值数组
ReDim t(1 To m) 展开
'逐步回归文件窗体
Option Explicit
Dim intI As Integer, intJ As Integer
Dim intFileNumber As Integer '文件号
Dim strData As String '临时保存数据
Dim blnTitle As Boolean '是否有标题
Dim blnRowLabel As Boolean '是否有行标
Dim blnColLabel As Boolean '是否有列标
Dim m1 As Integer
Dim n As Integer
Dim m As Integer
Dim b() As String
Private Sub Form_Load()
Form1.Show
File1.Pattern = "*.*" '只显示数据文件
End Sub
'选择目录
Private Sub Dir1_Change()
File1.Path = Dir1.Path
End Sub
'选择驱动器
Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive
End Sub
'确定数据文件
Private Sub File1_Click()
txtFile.Text = Dir1.Path & "\" & File1.FileName
End Sub
'确定,给出文件名和行数、列数后单击
Private Sub cmdOK_Click()
strFileName = txtFile.Text '文件名
intFileNumber = FreeFile '取得空闲的文件号码
Open strFileName For Input As intFileNumber
Input #intFileNumber, strData '读列数
intCol = Val(strData) '取得列数
If intCol >= 2 Then
For intI = 2 To intCol '空转,读*****
Input #intFileNumber, strData
Next intI
End If
Do Until EOF(1)
Input #intFileNumber, strData '读行数
intRow = Val(strData) '取得行数
If intCol >= 2 Then
For intI = 2 To intCol '空转,读*****
Input #intFileNumber, strData
Next intI
End If
Loop
Close intFileNumbe
n = intRow: m1 = intCol: m = m1 - 1
'重新定义变量数组
ReDim xy(1 To n, 1 To m1)
'保存回归系数组和工作单元
ReDim b(m)
'重新定义t检验值数组
ReDim t(1 To m) 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询