100分求解决 subscript out of range 问题

不知起什么名 2009-12-02 12:10:15
有些机子上就会出现,有些没有出现
subscript out of range
这个提示
请教是怎样解决
代码如下:


Private Sub mnuCompile_Click()
'<EhHeader>
On Error GoTo mnuCompile_Click_Err
'</EhHeader>
Dim StartTime As Single
Dim bCompileSucceed As Boolean

If gsProjectPathBase = "" Then
MsgBox IIf(mnuEnglish.Checked, "No project file.Please create a new project or open a project.", "当前没有项目文件。请新建项目或者打开已经存在的项目。"), vbCritical, SOFTWARE_NAME
Exit Sub
End If

If datWaveFile.Recordset.RecordCount = 0 And datMidiFile.Recordset.RecordCount = 0 Then
MsgBox IIf(mnuEnglish.Checked, "Empty project", "空项目。"), vbCritical, SOFTWARE_NAME
Exit Sub
End If

If mnuCompile.Tag = "Overflow" Then
MsgBox "容量溢出,请减小语音文件的大小后重新编译", vbExclamation
Exit Sub
End If

StartTime = Timer
Toolbar1.Buttons("build").Enabled = False
mnuCompile.Enabled = False
frmCompile.mSecondsPassed = 0
frmCompile.lblInfo.Caption = IIf(frmMain.mnuEnglish.Checked, "Compiling, please wait...", "正在编译,请稍候。。。")
frmCompile.lblTimeCost.Caption = IIf(frmMain.mnuEnglish.Checked, "Cost: 0s", "用时:0 秒")
frmCompile.Move Me.Left + (Me.Width - frmCompile.Width) / 2, Me.Top + (Me.Height - frmCompile.Height) / 2
frmCompile.txtBinFileName.Text = gsProjectPathBase & IIf(gChipModel = 5, "_25Pxx", "") & ".bin"
frmCompile.txtBinFileName.SelStart = 0
frmCompile.txtBinFileName.SelLength = Len(frmCompile.txtBinFileName.Text)
frmCompile.cmdCloseMe.Visible = False
frmCompile.cmdCOMDownload.Visible = False
frmCompile.cmdUSBDownload.Visible = False
frmCompile.cmdBrowse.Visible = False
' SetWindowAttributes frmCompile, True
frmCompile.tmrVaryProgressBarValue.Enabled = True
frmCompile.tmrShowSecond.Enabled = True
frmCompile.imgProgressBar.Move 0, frmCompile.ScaleHeight - frmCompile.imgProgressBar.Height, frmCompile.ScaleWidth
frmCompile.imgProgressBarBlock.Top = frmCompile.imgProgressBar.Top + 40
frmCompile.imgProgressBar.Visible = True
frmCompile.imgProgressBarBlock.Visible = True
frmCompile.Show vbModeless
frmCompile.Refresh
DoEvents

gsDataControlMode = CStr(gSystemMode)
gsOPState = CStr(gPwmDac)
gsSleepControl = CStr(gSleepFlag)
gsPort0PullUpControl = CStr(gP0Ph)
frmCompile.imgProgressBarBlock.Left = 75

If gChipModel = 5 Then
bCompileSucceed = Compile25PXX
Else
bCompileSucceed = CompileNormal
End If

Beep
frmCompile.tmrShowSecond.Enabled = False
frmCompile.tmrVaryProgressBarValue.Enabled = False
frmCompile.imgProgressBar.Visible = False
frmCompile.imgProgressBarBlock.Visible = False
If bCompileSucceed Then
frmCompile.lblInfo.Caption = IIf(frmMain.mnuEnglish.Checked, "Compile successful, please select your choice:", "编译完成,请选择您所需要的操作:")
Else
frmCompile.lblInfo.Caption = IIf(frmMain.mnuEnglish.Checked, "Compile failed, please contact us.", "编译失败,请将剪贴板中的信息发送给我们唯创公司。")
frmCompile.txtBinFileName.Text = Clipboard.GetText
End If

frmCompile.lblTimeCost.Caption = IIf(frmMain.mnuEnglish.Checked, "Cost: ", "用时:") & Format$(Timer - StartTime, "#.0") & IIf(frmMain.mnuEnglish.Checked, "s", "秒")
SetWindowAttributes frmCompile, False

Toolbar1.Buttons("build").Enabled = True

mnuCompile.Enabled = True

If bCompileSucceed Then
frmCompile.cmdBrowse.Visible = True
frmCompile.cmdCloseMe.Visible = True
frmCompile.cmdCOMDownload.Visible = True
frmCompile.cmdUSBDownload.Visible = True

If mnuAutoCOMDownloadAfterCompile.Checked Then
frmCompile.cmdCOMDownload_Click
ElseIf mnuAutoUSBDownloadAfterCompile.Checked Then
frmCompile.cmdUSBDownload_Click
Else
frmCompile.cmdCOMDownload.SetFocus
End If
End If

'<EhFooter>
Exit Sub

mnuCompile_Click_Err:
MsgBox Err.Description & vbCrLf & _
"in prjOTP.frmMain.mnuCompile_Click " & _
"at line " & Erl, _
vbExclamation + vbOKOnly, "Application Error"
Resume Next

...全文
696 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
linc_M 2009-12-02
  • 打赏
  • 举报
回复
好长,UP
slowgrace 2009-12-02
  • 打赏
  • 举报
回复
具体在哪一行报错?
不知起什么名 2009-12-02
  • 打赏
  • 举报
回复
这代码不是我写的,不过需要修改...

不知怎么下手..
Tiger_Zhao 2009-12-02
  • 打赏
  • 举报
回复
Subscript out of range / 下标越界(错误 9)
通常是访问数组/集合的成员时下标不正确。
由于有子函数的调用,错误不一定就在这个代码段中发生。

你的错误信息无法定位错误位置。
要让错误信息中的 Erl 起作用,就必须给每个语句加上行号,推荐使用 Mz-Tools。
jhone99 2009-12-02
  • 打赏
  • 举报
回复
参考一下

脚本超出范围。

脚本:脚本是使用一种特定的描述性语言,依据一定的格式编写的可执行文件,又称作宏或批处理文件。

这个说起来很复杂,不过一般是因为你的internet设置或者是防火墙之类的软件对脚本的限制。运行脚本是有风险的,所以如果没有必要就不要去解决了。当然,解决的办法一般就是更改internet(浏览器菜单:工具->Internet选项->高级)或者防火墙设置(情况不一,自己摸索)了。
不知起什么名 2009-12-02
  • 打赏
  • 举报
回复
怎么处理?
神马都能聊 2009-12-02
  • 打赏
  • 举报
回复

呃……脑子进水了,把下标越界看成溢出了
神马都能聊 2009-12-02
  • 打赏
  • 举报
回复
感觉可能是这里溢出了
StartTime = Timer

timer的来源是啥,在报错时加上timer的原始值看看。
特别 2009-12-02
  • 打赏
  • 举报
回复
不明白,帮顶一下
不知起什么名 2009-12-02
  • 打赏
  • 举报
回复
没有....

有时重装系统就可以了
jhone99 2009-12-02
  • 打赏
  • 举报
回复
有规律吗?
关于龙书第13章地形绘制的terrain项目运行出错问题 (注:龙书即:《DirectX9.0 3D游戏开发编程基础》) 在学习该教材时,当我们试着编译并运行13章地形绘制的terrain项目时,发现运行出错,并弹出了一个出错提示窗口,提示我们::访问vector 越界了 提示窗口的内容如下: -------------------------------------------------------------------- Microsoft Visual C++ Debug Library Debug Assertion failed! Program:...cuments and Settings\Administrator\Terrain\Debug\Terrain.exe File: d:\microsoft visual studio 10.0\vc\include\vector Line:932 Expression : vector subscript out of range For information on how your program can cause an assertion Failure , see the Visual C++ documentation on asserts. (Press Retry to debug the application) [终止(A)] [重试(R)] [忽略(I)] ---------------------------------------------------------------------------------- 问题主要出现在terrain.cpp 文件中的几个函数内部传递参数最终作为了vector的索引值,得到的索引值没有经过限定,导致超出了vector的界限-----最终访问越界. 修改的地方在下面这几处: 在terrain.cpp文档里搜索”//修改过!!!” bool Terrain::genTexture(D3DXVECTOR3* directionToLight) float Terrain::computeShade(int cellRow, int cellCol, D3DXVECTOR3* directionToLight) float Terrain::getHeight(float x, float z) 在terrain.cpp文档里搜索”//注意这里!!!” /int Terrain::getHeightmapEntry(int row, int col) bool Terrain::lightTerrain(D3DXVECTOR3* directionToLight) 在terrainDriver.cpp文档里搜索”//注意这里!!!” float height = TheTerrain->getHeight( pos.x, pos.z ); 我的修改主要是通过在传递索引值的地方,限定索引值的范围,这样就避免了vector访问越界,这也是龙书作者在写该13章的代码时一时所忽略掉的. 只修改过terrain.cpp文件中的内容,其他的都没动.所以可以只将terrain.cpp拷贝到工程中替换掉原来的就可以了.

679

社区成员

发帖
与我相关
我的任务
社区描述
智能路由器通常具有独立的操作系统,包括OpenWRT、eCos、VxWorks等,可以由用户自行安装各种应用,实现网络和设备的智能化管理。
linuxpython 技术论坛(原bbs)
社区管理员
  • 智能路由器社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧