VB程序题:输入一个字符串,分别调用UCase、Len、Mid、Left、Right函数,显示如图2.2.4所示的效果。
时间: 2024-06-06 15:07:24 浏览: 171
以下是VB程序代码:
```
Dim str As String
Dim lenStr As Integer
Dim midStr As String
Dim leftStr As String
Dim rightStr As String
str = InputBox("请输入一个字符串:")
lenStr = Len(str)
midStr = Mid(str, 2, 3)
leftStr = Left(str, 3)
rightStr = Right(str, 4)
MsgBox "UCase函数的结果:" & UCase(str) & vbCrLf & _
"Len函数的结果:" & lenStr & vbCrLf & _
"Mid函数的结果:" & midStr & vbCrLf & _
"Left函数的结果:" & leftStr & vbCrLf & _
"Right函数的结果:" & rightStr
```
运行程序后,将弹出一个输入框,让用户输入一个字符串。用户输入后,程序会调用各个函数,并将结果显示在一个消息框中,如下图所示:
![VB程序题2.2.4效果图](https://cdn.luogu.com.cn/upload/image_hosting/edc5a7e2.png)
阅读全文
相关推荐
![doc](https://img-home.csdnimg.cn/images/20241231044833.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![text/plain; charset=iso-8859-1](https://img-home.csdnimg.cn/images/20250102104920.png)
![doc](https://img-home.csdnimg.cn/images/20241231044833.png)
![-](https://img-home.csdnimg.cn/images/20241231044937.png)
![-](https://img-home.csdnimg.cn/images/20241231044901.png)
![-](https://img-home.csdnimg.cn/images/20241231044901.png)
![-](https://img-home.csdnimg.cn/images/20241231044833.png)
![-](https://img-home.csdnimg.cn/images/20241231044930.png)
![-](https://img-home.csdnimg.cn/images/20241231044930.png)
![-](https://img-home.csdnimg.cn/images/20241231044833.png)
![-](https://img-home.csdnimg.cn/images/20241231045021.png)
![-](https://img-home.csdnimg.cn/images/20241231044937.png)
![-](https://img-home.csdnimg.cn/images/20241231044833.png)
![-](https://img-home.csdnimg.cn/images/20241231044937.png)
![-](https://img-home.csdnimg.cn/images/20241231044901.png)