Results 1 to 4 of 4

Thread: Experet help! objects

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2000
    Posts
    113

    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

  2. #2
    Fanatic Member
    Join Date
    Sep 2000
    Location
    UK.
    Posts
    728

    Smile 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:
    1. Option Explicit
    2.  
    3. Private Sub Form_Load()
    4.     Dim i As Integer
    5.  
    6.     For i = 1 To 5
    7.         'CallByName Me, "Sub" & i, VbMethod - would also work.
    8.         CallByName Form1, "Sub" & i, VbMethod
    9.     Next i
    10.  
    11. End Sub
    12.  
    13. Public Sub Sub1()
    14.     Debug.Print "In Sub1..."
    15. End Sub
    16.  
    17. Public Sub Sub2()
    18.     Debug.Print "IN Sub2..."
    19. End Sub
    20.  
    21. Public Sub Sub3()
    22.     Debug.Print "In Sub3..."
    23. End Sub
    24.  
    25. Public Sub Sub4()
    26.     Debug.Print "In Sub4..."
    27. End Sub
    28.  
    29. Public Sub Sub5()
    30.     Debug.Print "In Sub5..."
    31. 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]

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Sep 2000
    Posts
    113
    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.

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Sep 2000
    Posts
    113

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width