📄 form1.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "查找第一个空格"
ClientHeight = 1815
ClientLeft = 60
ClientTop = 360
ClientWidth = 4725
LinkTopic = "Form1"
ScaleHeight = 1815
ScaleWidth = 4725
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command1
Caption = "查找"
Height = 495
Left = 3360
TabIndex = 1
Top = 240
Width = 1095
End
Begin VB.TextBox Text1
Height = 495
Left = 360
TabIndex = 0
Text = "Text1"
Top = 240
Width = 2655
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
'声明变量
Dim testStr As String
Dim s As String
Dim i As Integer
'赋初值
testStr = Text1.Text
i = 1
'使用循环查找
Do
s = Mid(testStr, i, 1)
If s = " " Then '找到空格
MsgBox "第一个空格位置为:" + Str(i)
Exit Do '跳出循环
End If
i = i + 1
Loop Until (i > Len(testStr)) '当到达字符串末尾时终止循环
If i = Len(testStr) + 1 Then
MsgBox "没有空格!"
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -