| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 518 人关注过本帖
标题:[求助] 怎么下标越界
只看楼主 加入收藏
lijie
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2007-5-22
收藏
 问题点数:0 回复次数:2 
[求助] 怎么下标越界

Option Explicit


Dim p(9) As rcd
Dim Matrix(9, 9) As Integer

Function seekSmall(a() As Integer)
Dim n, k, m, i, j As Integer
n = UBound(a) - 2
i = 1
m = a(0, 1): k = 0
Do While a(i, 1) <> 0
If a(i, 1) < m Then
m = a(i, 1): k = i
End If
i = i + 1
Loop
seekSmall = k
Print
End Function

Private Sub cmdContinue_Click()
MsgBox "请输入要求的路径," 'vbOKCancel
txtStart.Text = ""
txtEnd.Text = "'"
txtStart.SetFocus
txtPath.Text = ""
txtLength.Text = ""
End Sub

Private Sub cmdEnd_Click()
End
End Sub

Private Sub cmdOk_Click()
Dim nS, nE As Integer
Dim h As String
Dim i, j As Integer
Dim n As Integer
Dim x, y, z As Integer

' If txtStart.Text <> And txtEnd.Text <> Then
'nS = Val(txtStart.Text) - 1: nE = Val(txtEnd.Text) - 1 '确定起始点
'If (nS > 8 Or nE > 8) Then
' MsgBox ("没有该点,请重新输入正确的点")
'End If
'Else
'MsgBox ("没有输入")
'End If
p(0).In = nS '记录起始点
n = 0
For j = 0 To 8
If j <> nS Then
p(0).fT(n, 0) = j
p(0).fT(n, 1) = Matrix(nS, j)
n = n + 1
End If
Next j
p(0).jN = seekSmall(p(0).fT())
Print
p(0).judge = True
n = 0
For j = 0 To 8
If (j <> p(0).fT(p(0).jN, 0)) And (j <> nS) Then
p(0).bT(n, 0) = j
p(0).bT(n, 1) = Matrix(nS, j)
n = n + 1
End If
Next j
For i = 1 To 9
p(i).In = p(i - 1).fT(p(i - 1).jN, 0)
For j = 0 To 7 - i
If ((p(i - 1).bT(j, 1) >= (p(i - 1).fT(p(i - 1).jN, 1) + Matrix(p(i).In, p(i - 1).bT(j, 0)))) And ((p(i - 1).fT(p(i - 1).jN, 1)) + Matrix(p(i).In, p(i - 1).bT(j, 0)) < 100)) Then
If p(i - 1).bT(j, 0) = nE Then
If p(i - 1).bT(j, 1) >= (p(i - 1).fT(p(i - 1).jN, 1) + Matrix(p(i).In, p(i - 1).bT(j, 0))) Then
p(i).judge = True
End If
End If
p(i).fT(j, 1) = (p(i - 1).fT(p(i - 1).jN, 1) + Matrix(p(i).In, p(i - 1).bT(j, 0)))
p(i).fT(j, 0) = p(i - 1).bT(j, 0)
Else
p(i).fT(j, 1) = p(i - 1).bT(j, 1)
p(i).fT(j, 0) = p(i - 1).bT(j, 0)
End If
If p(i).fT(j, 0) = nE Then
If p(i).fT(j, 1) > 100 Then
p(i).judge = True
End If
End If
Next j
p(i).jN = seekSmall(p(i).fT())
n = 0
For j = 0 To 9 - i
If p(i).jN <> j Then
p(i).bT(n, 0) = p(i).fT(j, 0)
p(i).bT(n, 1) = p(i).fT(j, 1)
n = n + 1
End If
Next j
Next i
For i = 0 To 9
If p(i).In = nE Then
For j = 0 To i
If p(j).judge = True Then
h = h & (p(j).In + 1)
End If
Next j
txtLength.Text = p(i - 1).fT(nS, 1)
ElseIf i = 9 And p(i).In <> nE Then
For j = 0 To 9
If p(j).judge = True Then
h = h & (p(j).In + 1)
End If
Next j
txtLength.Text = p(7).fT(nS, 1)
End If
Next i

txtPath.Text = h & nE + 1
Open ("d:\1.txt") For Output As #1
For z = 0 To 9
Print #1,
Print #1, "----------------------------------------------------------;"
Print #1,
Print #1, p(z).In
For x = 0 To 9 - z
For y = 0 To 1
Print #1, p(z).fT(x, y);
Next y
Next x
Print #1,
Print #1, p(z).jN
For x = 0 To 8 - z
For y = 0 To 1
Print #1, p(z).bT(x, y);
Next y
Next x
Next z
For x = 0 To 8
Print #1,
Print #1, p(x).judge
Next x
Close

End Sub

Private Sub cmdOpen_Click()

Dim i, j As Integer


With CommonDialog1
CommonDialog1.Filter = "文档文件(*.txt)|*.txt|所有文件(*.*)|*.*"
CommonDialog1.ShowOpen
End With

Open CommonDialog1.FileName For Input As #1
While Not EOF(1)
For i = 0 To 8
For j = 0 To 8

Input #1, Matrix(i, j)
Next j
Next i
Print " 距离矩阵 "
For i = 0 To 8
For j = 0 To 8
Print Spc(3); Matrix(i, j);
Next j
Print
Next i
Wend
Close #1
End Sub
'Dim i, j As Integer
'On Error GoTo a:
'With CommonDialog1
'CommonDialog1.Filter = "文本文件(*.txt)|*.txt|所有文件(*.*)|*.*"
'CommonDialog1.ShowOpen
'End With
'
'Open CommonDialog1.FileName For Input As #1
'Do While Not EOF(1)
'For i = 0 To 8
'For j = 0 To 8
'Input #1, Matrix(i, j)
'Next j
'Next i
'Loop
'Close
'Open CommonDialog1.FileName For Input As #1
'txtEdit.Text = Input(LOF(1), 1)
'
'Close #1
'a:


搜索更多相关主题的帖子: 越界 
2007-05-22 15:22
milk713785
Rank: 1
等 级:新手上路
帖 子:39
专家分:0
注 册:2007-5-9
收藏
得分:0 
你用调试程序看看哪个下标越界啊,这不要看得累死

2007-05-22 23:14
Kendy123456
Rank: 10Rank: 10Rank: 10
等 级:贵宾
威 望:62
帖 子:2720
专家分:0
注 册:2007-1-3
收藏
得分:0 
错误出在哪一行 用颜色标出来

2007-05-23 11:16
快速回复:[求助] 怎么下标越界
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.080695 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved