473,396 Members | 2,029 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Call Function by string

BUX
If I want to call a function using a string i use the follow code:
Application.Run "MyFunction" and there is no problem.
But if MyFunction need parameters
Application.Run "MyFunction(myParameter)" do not work.
Do you know how can I do ?
thank you
Nov 13 '05 #1
6 13416
Try:

Application.Run "MyFunction", "myParameter"

This assumes myParameter is a string. Remove the quotes for numeric data
types, of course. If you have more than one parameter, just continue the
comma separated list.
--
David Lloyd
MCSD .NET
http://LemingtonConsulting.com

This response is supplied "as is" without any representations or warranties.
"BUX" <pi***@pippo.it> wrote in message
news:9f********************************@4ax.com...
If I want to call a function using a string i use the follow code:
Application.Run "MyFunction" and there is no problem.
But if MyFunction need parameters
Application.Run "MyFunction(myParameter)" do not work.
Do you know how can I do ?
thank you
Nov 13 '05 #2
BUX
It work, but I would like store the string
"MyFunction,myParameter1,myParameter2 ..."
in table.
The problem is that Visual Basic read the comma as text
rather than parameter separetor.

Nov 13 '05 #3
You may want to consider using the Eval function. For example,

Eval("MyFunction('MyStringParam', MyIntegerParam)")

Putting string parameters in single quotes appears to work.

--
David Lloyd
MCSD .NET
http://LemingtonConsulting.com

This response is supplied "as is" without any representations or warranties.
"BUX" <pi***@pippo.it> wrote in message
news:t0********************************@4ax.com...
It work, but I would like store the string
"MyFunction,myParameter1,myParameter2 ..."
in table.
The problem is that Visual Basic read the comma as text
rather than parameter separetor.
Nov 13 '05 #4
BUX
Sorry, it return run-time error 2425
'Impossible to find the function'

thank you for your help

On Wed, 27 Jul 2005 16:40:25 -0400, "David Lloyd"
<Da***@NoSpamPlease.com> wrote:
Eval("MyFunction('MyStringParam', MyIntegerParam)")


Nov 13 '05 #5
You may want to use Debug.Print to examine the string passed to the Eval
function. I did test this and it does work. It's hard to know where the
issue is without more specifics regarding your code.

--
David Lloyd
MCSD .NET
http://LemingtonConsulting.com

This response is supplied "as is" without any representations or warranties.
"BUX" <pi***@pippo.it> wrote in message
news:sr********************************@4ax.com...
Sorry, it return run-time error 2425
'Impossible to find the function'

thank you for your help

On Wed, 27 Jul 2005 16:40:25 -0400, "David Lloyd"
<Da***@NoSpamPlease.com> wrote:
Eval("MyFunction('MyStringParam', MyIntegerParam)")

Nov 13 '05 #6
BUX
I have found solution.
But is impossible set reference to vba6.dll from Access 2003 VBA.
But in VisualBasic.net it work perfectly!

'------------------------------------------
' (c) 1999 Trigeminal Software, Inc. All Rights Reserved
'------------------------------------------
'Thanks to ----------michka - Michael Kaplan
'Rest of code by Sergio Perciballi -oigres P (Aug-6-2000)

'Uses the function used by the immediate window
'to execute a line of code.
Option Compare Text
Option Explicit

Private Declare Function EbExecuteLine Lib "vba6.dll" _
(ByVal pStringToExec As Long, ByVal Foo1 As Long, _
ByVal Foo2 As Long, ByVal fCheckOnly As Long) As Long

' For VB5 IDE
'Declare Function EbExecuteLine Lib "vba5.dll" _
(ByVal pStringToExec As Long, ByVal Foo1 As Long, _
ByVal Foo2 As Long, ByVal fCheckOnly As Long) As Long

' FOR Access 97/VBE.dll clients like Word 97 and Excel 97
'Declare Function EbExecuteLine Lib "vba332.dll" _
(ByVal pStringToExec As Long, ByVal Foo1 As Long, _
ByVal Foo2 As Long, ByVal fCheckOnly As Long) As Long

Function FExecuteCode(stCode As String, _
Optional fCheckOnly As Boolean) As Boolean

FExecuteCode = EbExecuteLine(StrPtr(stCode), 0&, 0&,
Abs(fCheckOnly)) = 0
End Function

Private Sub Combo1_Click()
Text1.Text = Combo1.List(Combo1.ListIndex)
End Sub
Nov 13 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Sue | last post by:
After finishing up my first quarter JavaScript on 12/12/03, I decided to improve character checking on my project. In my project I only had to do very basic validation. Therefore, I only had one...
5
by: Rob | last post by:
Help me, I'm just beginning with programming in Access 2000. I've tried the http://www.mvps.org/access/api/api0001.htm but it won't work in Access. What am i doing wrong. I don't have...
5
by: Kurt Van Campenhout | last post by:
Hi, I am trying to get/set Terminal server information in the active directory on a windows 2000 domain. Since the ADSI calls for TS don't work until W2K3, I need to do it myself. I'm fairly...
5
by: SStory | last post by:
Hi all, I really needed to get the icons associated with each file that I want to show in a listview. I used the follow modified code sniplets found on the internet. I have left in...
0
by: Pawan Narula via DotNetMonster.com | last post by:
hi all, i'm using VB.NET and trying to code for contact management in a tree. all my contacts r saved in a text file and my C dll reads them one by one and sends to VB callback in a sync mode...
18
by: Lars Netzel | last post by:
Hello! Thanx to this newgroup I have finally, with the help of you guys, gotten this to work halfway.. but the final action is still not working, clicking the "Button2" thru SendMessage(). ...
5
by: Lee | last post by:
(I also posted this query in Microsoft.Public.DotNet.Framework yesterday, but since I have received no responses, I am posting it here too.) Using Windows XP with all updates applied and Visual...
0
by: Mike S | last post by:
I've seen examples of using the CallWindowProc Windows API function to call functions through their addresses in VB6 -- a clever workaround to emulate C-like function pointer semantics. A...
9
by: Allen | last post by:
The arguments of function is variable. Given function address, argument type and data, how to dynamically call the function? The following is pseudo code. int count = 0; int offset = 0; char...
5
by: =?Utf-8?B?cGVsZWdrMQ==?= | last post by:
how can i call a function where i recive its name from a query string and i want to call that function (in asp it was with Eval function) and how can i call it if i have parameters too? thnaks...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.