Excel 在 VBA 中,如何获取 Function 的返回值
3个回答
展开全部
请测试一下,可据实修改:
Function GetTextPair(Optional docStyle As String = "TTK", Optional bTag As String = "{[", Optional eTag As String = "]}") As String
Dim bPosition As Long
Dim ePosition As Long
Dim textPair As String
Dim temp As String
temp = ""
With Selection
.Start = 0
.End = 0
End With
With Selection.Find
.ClearFormatting
.Style = docStyle
.Format = True
.Forward = True
.Text = ""
.Wrap = wdFindStop
Do While .Execute = True
textPair = Selection.Text
bPosition = InStr(textPair, bTag) + 2
ePosition = InStr(textPair, eTag)
If bPosition > 0 And ePosition > 0 Then
temp = temp & "||||" & Mid$(textPair, bPosition, ePosition - bPosition)
End If
Loop
End With
GetTextPair = temp
End Function
Sub Example()
MsgBox GetTextPair
End Sub
Function GetTextPair(Optional docStyle As String = "TTK", Optional bTag As String = "{[", Optional eTag As String = "]}") As String
Dim bPosition As Long
Dim ePosition As Long
Dim textPair As String
Dim temp As String
temp = ""
With Selection
.Start = 0
.End = 0
End With
With Selection.Find
.ClearFormatting
.Style = docStyle
.Format = True
.Forward = True
.Text = ""
.Wrap = wdFindStop
Do While .Execute = True
textPair = Selection.Text
bPosition = InStr(textPair, bTag) + 2
ePosition = InStr(textPair, eTag)
If bPosition > 0 And ePosition > 0 Then
temp = temp & "||||" & Mid$(textPair, bPosition, ePosition - bPosition)
End If
Loop
End With
GetTextPair = temp
End Function
Sub Example()
MsgBox GetTextPair
End Sub
展开全部
使用等号就可以,例如函数abs,要获得去返回值在变量x中,语句为:
x = abs(-5)
x = abs(-5)
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2018-03-02 · 知道合伙人软件行家
关注
展开全部
直接等于就可以吧? a=MyFunction
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询