vb.net - VB.NET:部分代码根本不执行
问题描述
我在 VB.NET 中有包含两个嵌套 For 语句的代码。例如
For i = 0 to ListBox1.Items.Count - 1
MsgBox("First For statement")
For x = 5 to 1
MsgBox("Second For statement")
Next
Next
现在第一个 For 语句执行得很好,但第二个没有。怎么来的?代码不应该逐行执行吗?
解决方案
Vb.net 中的 For 循环语法:
For counter [ As datatype ] = start To end [ Step step ]
[ statements ]
[ Continue For ]
[ statements ]
[ Exit For ]
[ statements ]
Next [ counter ]
您错过了代码中的步骤
For x = 5 to 1 step -1
MsgBox("Second For statement")
Next
推荐阅读
- linux-kernel - KVM/QEMU 和客户操作系统如何处理页面错误
- angular - 无需重新加载页面的角度路由/切换组件
- python - 如何使用 selenium 与 tabindex = -1 交互表单
- vue.js - 使用 Heroku Strapi 后端将 vue/nuxt 应用程序部署到 Netlify 时出错
- django - Django Zappa Lambda 部署“botocore.errorfactory.ResourceNotFoundException”
- javascript - 定制 Javascript 库的“现代”方式
- java - 通过 Selenium 运行 JUnit 测试用例时出错
- c# - 使用 OpenAPI 操作过滤器向需要身份验证的控制器端点添加安全要求
- java - RxJava Android:观察者不兼容类型错误
- sql-server - 剩余分配空间的 10% 时删除事务日志