在VB中 在字符串中怎样提取特殊位置的字符
发布网友
发布时间:2022-09-16 23:36
我来回答
共3个回答
热心网友
时间:2023-11-05 10:17
Private Sub Command1_Click()
Dim x%, y$, z%, r$
y = InputBox("请输入一组字符串")
x = Len(y)
For z = 1 To x Step 2
r = r & Mid(y, z, 1)
Next
Text1 = y & "抽取之后为:" & r
End Sub
另外,我起问下一楼回答者: (oaita - )
getResultStr是什么函数,怎么不能运行,是不是你的字母有误呢,还请指教!
热心网友
时间:2023-11-05 10:17
Private Sub Command1_Click()
Dim a As String
a = "abcdefg"
Debug.Print getResultStr(a)
End Sub
Private Function getResultStr(ByVal str As String) As String
Dim i As Long
Dim outstr As String
For i = 1 To Len(str)
If i Mod 2 <> 0 Then
'说明是奇数
outstr = outstr & Mid(str, i, 1)
End If
Next
getResultStr = outstr
End Function
热心网友
时间:2023-11-05 10:18
Private Sub Command1_Click()
Dim str, r As String, i As Long
str = "ABCDEFG"
For i = 1 To Len(str) Step 2
r = r & Mid(str, i, 1)
Next i
MsgBox r
End Sub