|
-
Sep 2nd, 2001, 10:49 PM
#1
Thread Starter
Lively Member
Experet help! objects
ok im trying to find out how CallByName works because i want to be able to use just a string to change/get a value from a object.
You (need) an object as object
i want to use a number or (pointer) insted of the object!
or i would like to know how CallByName uses the object....
CallByName (object as object, string, callType, value)
'a string of objects and =
strsing = "objectvar.Show_item_values.caption = 1"
'build a list of the objects
oldtonext = 1
For a = 1 To 5 'only need
tonext = InStr(oldtonext, strsing, ".")
If tonext = 0 Then
tonext = InStr(oldtonext, strsing, " ")
If tonext = 0 Then Exit For 'error
End If
Tobject(a) = Mid(strsing, oldtonext, tonext - oldtonext)
oldtonext = tonext + 1
Next a
'Find what the object =
'if number
If InStr(1, strsing, "= ") > 0 Then TobjectE = Mid(strsing, InStr(1, strsing, "= ") + 2, Len(strsing) - InStr(1, strsing, "= "))
'if string
If InStr(1, strsing, "=$ ") > 0 Then TobjectE = Mid(strsing, InStr(1, strsing, "=$ ") + 3, (Len(strsing) - InStr(1, strsing, "=$ ") + 3) - 1)
Dim asdsa As Object
Set asdsa = objectVAR 'Tobject(1) ####this is where it happons
CallByName asdsa, Tobject(2) + "." + Tobject(3), VbSet, TobjectE
-
Sep 3rd, 2001, 07:51 AM
#2
Fanatic Member
Info.
You (need) an object as object
i want to use a number or (pointer) insted of the object!
The call by name function takes in an object, and a string
and invokes the particular method/property etc specified in the string of the specified object. You need to pass in a valid object.
i.e. Create a form with the following code. There are 5 subs.
We can call each from within a loop, by using the call by name function.
VB Code:
Option Explicit
Private Sub Form_Load()
Dim i As Integer
For i = 1 To 5
'CallByName Me, "Sub" & i, VbMethod - would also work.
CallByName Form1, "Sub" & i, VbMethod
Next i
End Sub
Public Sub Sub1()
Debug.Print "In Sub1..."
End Sub
Public Sub Sub2()
Debug.Print "IN Sub2..."
End Sub
Public Sub Sub3()
Debug.Print "In Sub3..."
End Sub
Public Sub Sub4()
Debug.Print "In Sub4..."
End Sub
Public Sub Sub5()
Debug.Print "In Sub5..."
End Sub
Hope ths helps 
Laterz
Digital-X-Treme
Contact me on MSN Messenger: [email protected]
[VBCODE]Debug.Print Round(((1097) - ((55 ^ 5 + 311 ^ 3 - 11 ^ 3) _
/ (68 ^ 5))) ^ (1 / 7), 13)[/VBCODE]
-
Sep 3rd, 2001, 09:51 AM
#3
Thread Starter
Lively Member
sorry my question is foggy.
what im looking for is another way of using CallByName.
i want to find out how callByname uses the object as object to locate the list of names of the object in it.
CallByName (object as object , string, callType, value)
or where would i go to findout.
-
Sep 3rd, 2001, 10:44 AM
#4
Thread Starter
Lively Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|