Have anyone made a CallByName for VB5 probably using API?
Printable View
Have anyone made a CallByName for VB5 probably using API?
What fo you mean by a CallByName Function???????How should it work, hoe do you want it to work?????
CallByName is a new function in VB6 and not for others old VB version.
sample code:Code:CallByName (Object, Procedure, Calltype, [Arguments()])
Hope this will help. :)Code:Private Sub cmdQuery_Click()
Dim sType as String
Dim vControl as Variant
On Error GoTo errorhandler
For Each vControl In Controls
If vControl.Name = txtObject.Text Then
Exit For
End If
Next
If chkProp.Value = vbChecked Then
If chkLet.Value = vbChecked Then
CallByName vControl, txtPropMeth.Text, vbLet, txtValue
Else
txtValue = CallByName(vControl, txtPropMeth, vbGet)
End If
Else
CallByName vControl, txtPropMeth.Text, vbMethod
End If
Exit Sub
errorhandler:
MsgBxo Err.Description
End Sub
Am using VB5 SP3...............sad but true
Call by name has some interesting uses.
I have only used it once in a cut-down version of an XML parser which never saw the light of day :)
I had one program running on one system and text arriving through the winsock in pseudo XML format could make RPC (Remote procedure calls) out of it.
It is of course possible to have a case statement on the incoming text and call the function but I wanted to add new functions to the program and have the client software just call them from a text based browser.
You can just pass a string containing the function name and it will call it.
It's slower then proper function calls by a long way, you'd never use it in a performance algorithm but it can be used to "Open up" an app to the outside.
VB5...
Not any way I can think of to create this funtion youself but I can't see why you couldn't imitate the functionality you need, it's not really that usefull and usually (unless I'm missing the point of it) there is a better way of writing the program without it. To me it was a cheap and dirty short cut.