交付功能以运行到另一个功能(在VBA中的Paramaterizing?) [英] Hand in function to run to another function (Paramaterizing in VBA?)

查看:70
本文介绍了交付功能以运行到另一个功能(在VBA中的Paramaterizing?)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,



我在VBA工作(特别是excel)。我需要从格式不正确的文本文件中提取数据。我的搜索功能正在运行,但我正在尝试简化代码(删除冗余)。



具体来说,我想在成功搜索时运行一个函数来运行out,Sudo代码示例:

Hello,

I'm working in VBA (in excel specifically). I need to pull data out of poorly formatted text files. I have my search functions working, but am trying to streamline the code (remove redundancy).

Specifically I want to hand a function to run when a successful search is caried out, Sudo Code Example:

Private Function magicSearchFunction(searchString As String, functionToRun As String)

'Magic search done here

If Successful
	'Run specific function that was handed in "functionToRun"
End If

End Function





我通常不在VB工作,所以很抱歉,如果这是一个新问题。我知道我可以在C#中做到这一点(像这样的{0},stuffToDo)



或者我需要为每次搜索都有一份搜索功能需要在如果成功区域执行不同的任务,jsut似乎是糟糕的编程技术。



提前感谢您提供的任何帮助!



I usually don't work in VB so sorry if this is a newb question. I know I can do this in C# (like this "{0}, stuffToDo")

Alternatively I will need to have a copy of my search functions for each search that needs to perform different tasks in the "If Successful" area, which jsut seems like poor programming technique.

Thanks in advance for any help you can offer!

推荐答案

您可以使用Application.Run方法。请参阅此处的示例, http://stackoverflow.com/questions/19845944/dynamic- function-calls-in-excel-vba [ ^ ]
You can use the Application.Run method. See here for an example, http://stackoverflow.com/questions/19845944/dynamic-function-calls-in-excel-vba[^]


这篇关于交付功能以运行到另一个功能(在VBA中的Paramaterizing?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆