[Super Simple VB Intro] 8. Four Types of Operations
Preface These past few days it seems a lot of students have been reading this VB tutorial series. A little classmate said it was pretty well written hehe, so I've got the motivation to keep updating. Just a heads-up, it's being updated on both the WeChat official account and the blog at the same time, and because the blog can be written in Markdown, the layout is a bit more comfortable. If it's convenient, I suggest you read it on the blog. Blog address: blog.deali.cn Arithmetic Operations Arithmetic operations include addition (+), subtraction (-), multiplication (*), division (/), integer division (\) (e.g. 7\2 equals 3), modulo (Mod) (used to get the remainder, e.g. 7
目录5 个章节
Preface
These past few days it seems a lot of students have been reading this VB tutorial series. A little classmate said it was pretty well written hehe, so I've got the motivation to keep updating. Just a heads-up, it's being updated on both the WeChat official account and the blog at the same time, and because the blog can be written in Markdown, the layout is a bit more comfortable. If it's convenient, I suggest you read it on the blog. Blog address: blog.deali.cn
Arithmetic Operations
Arithmetic operations include addition (+), subtraction (-), multiplication (*), division (/), integer division () (e.g. 7\2 equals 3), modulo (Mod) (used to get the remainder, e.g. 7Mod2 equals 1, because 7=3 x 2 + 1, so the remainder is 1, this seems to be middle school math knowledge = =..), exponentiation (^), and unary minus (negating a number; two negatives make a positive, e.g. - (-6) equals 6).
Concatenation Operations
Concatenation operations join two character expressions together to produce a new string. There are two concatenation operators: + and &.
- When using the & operator, the two expressions being concatenated do not both have to be strings; that is, the & operator can forcibly concatenate the two expressions as strings. For example:
Dim intNum As Interger
Dim strTemp As String
intNum = 22
strTemp = "学号是" & intNum
- When using the + operator, the operands must be strings; otherwise, an error is produced. The following code is incorrect!
Dim intNum As Interger
Dim strTemp As String
intNum = 22
strTemp = "学号是" + intNum
You might not feel much after reading this, but later in development, the & operator is extremely useful, and really handy.
Relational Operations
Relational operations are used to compare the magnitude of two expressions, including greater than (>), greater than or equal to (>=), less than (<=), less than or equal to (<=), equal to (=), and not equal to (<>). The result of a relational operation is the logical value True or False. Here are a few small examples; see the table below:
| Expression | Operation Type | Value | Description |
|---|---|---|---|
1=2 | Equal | False | 1 equals 2, clearly wrong, so the result is false |
1=1 | Equal | True | 1 equals 1, correct, the result is true |
1>2 | Greater than | False | 1 greater than 2, that's wrong |
1<2 | Less than | True | 1 less than 2, correct |
1<1 | Less than | False | 1 less than 1, incorrect, 1 and 1 are equal |
1<=1 | Less than or equal | True | 1 less than or equal to 1, correct |
Logical Operations
Logical operations are also called Boolean operations, specifically used for operations between logical values. See the table below:
| Operator | Meaning | Example | Result | Description |
|---|---|---|---|---|
| Not | Logical NOT | Not(8>2) | False | 8 greater than 2 is true, negated becomes false. |
| And | Logical AND | (8>2)And(9>3) | True | True only when both expressions are true. |
| Or | Logical OR | (8>3)Or(9<5) | True | True when either of the two expressions is true. |
| Xor | Exclusive OR | (9>5)Xor(21>6) | False | True only when one and only one of the two expressions is true. |
| Eqv | Logical equivalence | (6―3)Eqv(8―5) | True | True only when the two expressions are the same. |
| Imp | Logical implication | (9<6=Imp(9>8) | False | True only when the first expression is true. |
If you have any questions or want to discuss, you can contact me through the WeChat official account.
WeChat official account: DealiAxy

Blog address: blog.deali.cn
_EOF_
[Super Simple VB Intro] 8. Four Types of Operations
- 本文作者:
- 程序设计实验室
- 版权声明:
- 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
相关文章
关于《VB超简单入门》
查看全部内容请移步到我博客里的专题:DealiAxy's VB-Simple-Guide 有什么问题或者需要交流的同学可以通过微信公众号和我联系。 微信公众号:DealiAxy 博客地址:blog.deali.cn
2022-02-10 · VB入门教程 · 约 1 分钟
【VB超简单入门】二、知识准备
在开始编程之前,需要先熟悉一下各种操作和术语,以后学习编程才能得心应手。 首先最重要的操作当然就是…电脑的开机关机啦~(开个玩笑哈哈),必须掌握软件的安装和卸载,还有能编写批处理程序对平时的使用也是很有帮助的。 关于各种操作列个表~~ (由于时间关系,先列出相关点,详细操作以后我会慢慢补充~) l 查看、编辑注册表:使用regedit.exe修改系统注册表,我们写程序有时需要将程序的相关配置保存到
2022-11-13 · VB入门教程 · 约 1 分钟
【VB超简单入门】九、程序执行顺序-1
前言 最近作者很忙啦,这个系列的教程更新得也比较慢,在公众号后台看到有同学在催更了,所以抽出时间写一篇哈~ 有同学担心我没时间继续更新下去,这里再重申一下,只要有人看我就会抽出时间继续更新的啦,请大家放心哈。 关于程序执行顺序 我们写程序的时候,是一行一行的写的,在程序运行的时候,也是一行一行的运行,不过现实中的需求都是非常复杂的,如果只能一行一行运行的话,那我们的程序就不能叫做「程序」了,只能称
2022-11-13 · VB入门教程 · 约 1 分钟
【VB超简单入门】一、写在前面
前言 每本书的前面总得写点什么,到我这里也自然不能免俗,前言这东西“存在即合理”,所以就随便写一点咯~ 首先这本书是给从未接触过编程的童鞋准备的,由于我学识疏浅,对VB也只是一知半解所以也只能讲一点点最基础的知识,入门之后便可以自由学习更高级的东西了~ 编程其实并不难,有很多人一看到屏幕上密密麻麻的代码就被吓呆了= =… 也有很多童鞋问我编程是不是得背很多代码= =…其实根本不用背,编程涉及的单词
2022-11-13 · VB入门教程 · 约 1 分钟
讨论
共 0 条加载评论中…