CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2001
    Posts
    7

    Building Frame names using strings

    HI, I have 90 Frames that I want to check to see if the option box has been checked. I can make 90 if statements, ie Frame1, Frame2, ...Frame90, or use one loop as the only thing that changes is the number of the Frame, which is sequential ie 1,2,3,4,5,..90. See how much code I would save. When I build the frame name with a string & number etc... ie Frame1.value as "Frame" & number & "Value" I get an error! is there a way to do this? Visual BAsic sees it as a string, not as the name of an object etc... thanks very much


  2. #2
    Join Date
    Apr 2000
    Posts
    737

    Re: Building Frame names using strings

    you can loop through each control in a form like this


    dim formctrl

    for each formctrl in Form1 'assume Form1 is the form name

    if typeof formctrl is Frame then

    'check the option box for this frame
    end if

    next formctrl





    HTH

    cksiow
    http://vblib.virtualave.net - share our codes


  3. #3
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: Building Frame names using strings

    cksiow is right. and if you want to do different things with name of frame, you can use:
    dim formctrl
    for each formctrl in Form1 'assume Form1 is the form name
    if typeof formctrl is Frame then 'check the option box
    if formctrl.name = "Frame" & number then 'this do works: you're matching strings
    end if
    end if
    next formctrl


    Special thanks to Lothar "the Great" Haensler, Tom Archer, Bruno Paris and all the other wonderful people who made and make Codeguru a great place. Come back soon, you Gurus.
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

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

Featured