Este codigo que les dejo me arreglo una duda que tenia la cual me la respondio Google a una liga interesante ( Almenos para mi xP )
intentaba hacer algo similar a esto:
Código (Vb) [Seleccionar]
Private Sub Form_Load()
Dim Args() As Variant
ReDim Args(0 To 1)
Args(0) = "hola Mundo"
Args(1) = "12"
CallByName Me, "Mensaje", VbMethod, Args()
End Sub
Public Sub mensaje(mensaje As String, Optional hola As Long)
MsgBox mensaje, vbOKOnly, hola
End Sub
pero no daba y google me respodio:
http://www.devx.com/tips/Tip/15422
Código (vb) [Seleccionar]
' Required for use in VB5!
Public Enum VbCallType
VbMethod = 1
VbGet = 2
VbLet = 4
VbSet = 8
End Enum
Public Function CallByNameEx(Obj As Object, _
ProcName As String, CallType As VbCallType, _
Optional vArgsArray As Variant)
Dim oTLI As Object
Dim ProcID As Long
Dim numArgs As Long
Dim i As Long
Dim v()
On Error GoTo Handler
Set oTLI = CreateObject("TLI.TLIApplication")
ProcID = oTLI.InvokeID(Obj, ProcName)
If IsMissing(vArgsArray) Then
CallByNameEx = oTLI.InvokeHook( _
Obj, ProcID, CallType)
End If
If IsArray(vArgsArray) Then
numArgs = UBound(vArgsArray)
ReDim v(numArgs)
For i = 0 To numArgs
v(i) = vArgsArray(numArgs - i)
Next i
CallByNameEx = oTLI.InvokeHookArray( _
Obj, ProcID, CallType, v)
End If
Exit Function
Handler:
Debug.Print Err.Number, Err.Description
End Function
con lo cual ahora el CallByName bueno mejor dicho CallByNameEx acepta ahora expresiones de este tipo:
Código (vb) [Seleccionar]
Call CallByNameEx(Me, "xx", VbMethod, x)
Call CallByNameEx(Me, "xx", VbMethod, Array(1, 2))
Result=CallByNameEx(Me, "xx", VbMethod, x)
siendo que antes array() o pasandole un vector a CallByName No servia
Código (Vb) [Seleccionar]
Private Sub Form_Load()
Dim Args() As Variant
ReDim Args(0 To 1)
Args(0) = "hola Mundo"
Args(1) = "12"
CallByNameEx Me, "Mensaje", VbMethod, Args()
End Sub
Public Sub mensaje(mensaje As String, Optional hola As Long)
MsgBox mensaje, vbOKOnly, hola
End Sub
Sangrienta Luna Infernal!¡.