Results 1 to 6 of 6

Thread: For Each Loop

  1. #1

    Thread Starter
    Hyperactive Member onerrorgoto's Avatar
    Join Date
    Aug 1999
    Location
    Sweden
    Posts
    330

    Question

    Hello

    I'm not very good about this control-collection stuff.

    I'm trying to make 2 sub's that takes a form as argument and then checkes if there is any timer in that form.
    Sub1 disables the timer & Sub2 Enables the timer.

    I tried with
    Code:
    Publc sub DisAbleTimer(Frm as Form)
    Dim Ctrl as Control
     For Each Ctrl in Frm
       if Ctrl=Timer then 
       Ctrl.Enable=False 'make it disabled
       end if
     next Ctrl
    End Sub
    But it didn't work. Any ideas about how to do this??

    I'm using VB5 SP3 on this project.
    Thank you

    Onerrorgoto

    Dont be to optimistic, the light at the end of the tunnel might be a train

  2. #2
    Fanatic Member
    Join Date
    Mar 2000
    Location
    That posh bit of England known as Buckinghamshire
    Posts
    658
    You need to use the typeName function to return what type of contorl it is.

    Code:
    Publc sub DisAbleTimer(Frm as Form)
    Dim Ctrl as Control
     For Each Ctrl in Frm
       if typeName(Ctrl) = Timer then 
       Ctrl.Enable=False 'make it disabled
       end if
     next Ctrl
    End Sub
    Iain, thats with an i by the way!

  3. #3
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Use the Typename function:
    Code:
    Publc sub DisAbleTimer(Frm as Form)
    Dim Ctrl as Control
     For Each Ctrl in Frm
       if TypeName(Ctrl) = "Timer"
     then 
       Ctrl.Enable=False 'make it disabled
       end if
     next Ctrl
    End Sub
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  4. #4

    Thread Starter
    Hyperactive Member onerrorgoto's Avatar
    Join Date
    Aug 1999
    Location
    Sweden
    Posts
    330

    Question Typename in VB5

    Thank you both the speedy reply :0)
    a few additional Q's for this topic.

    Is Typename avaible in VB 5??

    Is it TypeOf that is a VB6-function?

    Can I use VB6-functions in VB5 if I have the Msvbvm60.dll in my machine?

    If so do I have to deliver the Msvbvm50.dll with my setup if I deliver the Msvbvm60.dll-file??

    just qurious
    Onerrorgoto

    Dont be to optimistic, the light at the end of the tunnel might be a train

  5. #5
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    1. Typename and TypeOf are both in VB5 Enterprise Edition

    2. You can only use Msvbvm60.dll for compiled vb6 code
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  6. #6

    Thread Starter
    Hyperactive Member onerrorgoto's Avatar
    Join Date
    Aug 1999
    Location
    Sweden
    Posts
    330

    Thumbs up Good

    Thank you Kedaman

    Then I can saftly use TapeName or TypeOf within my app.
    Onerrorgoto

    Dont be to optimistic, the light at the end of the tunnel might be a train

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