当前位置:网站首页>VB 学习笔记
VB 学习笔记
2022-06-24 20:23:00 【全栈程序员站长】
大家好,又见面了,我是你们的朋友全栈君。
这一个月由于工作的需要,学习了一点 VB.net 操作 Excel,记录一下笔记
vb 里面的下标
vb 里面的下标有三种:
- 从 0 开始:当我们在 vb 中定义一个数组时,下标只能从 0 开始
Dim arr(2) as String中的 arr 数组长度为3注意不是2Dim arr(1 to 10) as String则会报错数组的下限只能是 0
- 从 1 开始:主要用于从 0 开始会引发异常的 collections 比如 Tabs, Pages, Controls(listBox, TextBox),Excel 里面的复杂类型下标都是从 1 开始
- 字典类型 下标为键值
在代码中尽量使用 LBound 和 UBound 来获取数组最小和最大下标,可以在模块中使用option base 1 来指定下标从 1 开始
关于 Excel lastUsedRow 和 lastUsedColumn
Excel 中 Worksheet.UsedRange.Rows 是指 Excel 工作簿中第一个不为空的行到最后一个不为空的行之间的行数 R,所以如果工作簿中一开始有空行的话,最后返回的结果为「R – 开头空的行数」,所以可能不是我们所预期的结果。
所以不要依靠 Worksheet.UsedRange.Rows 来获取最后一行而应该使用参考链接的方法
为什么 vb 中使用 Worksheet.UsedRange.Rows.Count 得到的结果是错的
关于 vb 的异常处理
VB 中使用 try catch 捕获异常,使用 throw 抛出异常。
但是如果有两个类分别在两个模块中,想在 A 类模块的函数中调用 B 类中的函数并捕获 B 类函数的异常,就会报个警告:Exception 类型异常在「模块 2」中发生但未处理
# 模块 1
Public Class Test1
Private T = new Class Test2
Private Sub test1()
Try
T.Test()
Catch ex as Exception
MsgBox(ex.message)
End Try
End Sub
End Class
# 模块 2
Public Class Test2
Public Sub Test()
Throw new Exception(“error”)
End Sub
End Class发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/151918.html原文链接:https://javaforall.cn
边栏推荐
- Scala sample class
- 移动安全工具-jar
- Text editor for QT project practice - Episode 10
- 2022年危险化学品经营单位安全管理人员考试试题及模拟考试
- Punch smart spirit 1. The brand is attractive. What is the strength of the product?
- Sanic service startup failed
- Thermodynamic diagram display correlation matrix
- 【Redis实现秒杀业务④】一人一单,不可重复购买
- Examination questions and mock examination for safety management personnel of hazardous chemical business units in 2022
- Danish Technical University pioneered the application of quantum computing to power flow modeling of energy system
猜你喜欢

丹麦技术大学首创将量子计算应用于能源系统潮流建模

QT electronic clock

QT(35)-操作EXCEL-QXlsx-QAxObject

2022 melting welding and thermal cutting recurrent training question bank simulated examination platform operation
![[microservices sentinel] sentinel quick start | building an image | starting the console](/img/88/a01c8120f6117f1b8e4463cf6f685f.png)
[microservices sentinel] sentinel quick start | building an image | starting the console

Databinding quick start (still using findviewbyid?)

Xcode预览(Preview)显示List视图内容的一个Bug及解决

Activity startup process

Custom animation (simulated win10 loading animation)

Network request -volley
随机推荐
Realization of MNIST handwritten numeral recognition
ImageView展示网络图片
Scala sample class
Syntax highlighting of rich text
2021-02-15
Thingsboard - rest API obtains and refreshes tokens
Infotnews | is the development of domestic NFT limited to digital collections?
【微服务|Sentinel】实时监控|RT|吞吐量|并发数|QPS
Text editor for QT project practice -- Episode 9
Redis + Lua implementation of distributed interface current limiting
adb shell sendevent
Previous basic review
Add information on the left and add parts on the right of the status bar
【Redis实现秒杀业务④】一人一单,不可重复购买
ros(25):rqt_ image_ View reports an error unable to load plugin for transport 'compressed', error string
Mobile security tool -dex2jar
Mobile security tool jarsigner
adb shell getevent
QT(36)-rapidjson解析嵌套的json
Helm chart仓库操作