Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 253
Default how to call a function with variance which is function Name

Hi,


Use Run (to call a SUB, which is not a function)
A function return a value, not a sub


Sub test()
MsgBox "tesst"
End Sub

Sub testcall()
Dim str As String
str = "test"
Run str
End Sub

Regards,
Jean-Yves

"miao jie" wrote in message
...
Hi,
now I have a case to wanna use a string variance stand for function

name
to call a function, but I'm fail to do it. my test program as follow,
Sub test_call_function()
Dim functionName As String

functionName = "test_split_string"

' Call functionName("dss")
functionName "dss"
End Sub

Sub test_split_string(ByVal test As String)
Dim fieldArry
Dim i As Integer

fieldArry = Split("24354.54,34546.5,3324.67", ",")
For i = 0 To UBound(fieldArry, 1)
MsgBox fieldArry(i)
Next
MsgBox test
End Sub

the VBA tell me a compile error for
functionName "dss"

anyone can show me a way to use variance as function name to call it.

thanks
in advance.



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default how to call a function with variance which is function Name

Use Run (to call a SUB, which is not a function)

Run can be used to call a function as well as a sub.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"Jean-Yves" wrote in message
...
Hi,


Use Run (to call a SUB, which is not a function)
A function return a value, not a sub


Sub test()
MsgBox "tesst"
End Sub

Sub testcall()
Dim str As String
str = "test"
Run str
End Sub

Regards,
Jean-Yves

"miao jie" wrote in message
...
Hi,
now I have a case to wanna use a string variance stand for

function
name
to call a function, but I'm fail to do it. my test program as

follow,
Sub test_call_function()
Dim functionName As String

functionName = "test_split_string"

' Call functionName("dss")
functionName "dss"
End Sub

Sub test_split_string(ByVal test As String)
Dim fieldArry
Dim i As Integer

fieldArry = Split("24354.54,34546.5,3324.67", ",")
For i = 0 To UBound(fieldArry, 1)
MsgBox fieldArry(i)
Next
MsgBox test
End Sub

the VBA tell me a compile error for
functionName "dss"

anyone can show me a way to use variance as function name to

call it.
thanks
in advance.





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there a do not call function? pokdbz Excel Discussion (Misc queries) 2 December 27th 07 04:00 PM
how i can call the function reneabesmer Excel Worksheet Functions 2 May 2nd 05 12:13 PM
How to call EOMONTH(a, b) function Lee Dengo Excel Programming 1 May 10th 04 07:05 PM
Function Call Phil Hageman Excel Programming 4 October 9th 03 04:32 PM
call function sirron Excel Programming 1 August 26th 03 03:39 PM


All times are GMT +1. The time now is 05:07 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"