Results 1 to 7 of 7

Thread: Subtract 30 from all controls on form - their height and top positions?

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    May 2006
    Posts
    2,295

    Subtract 30 from all controls on form - their height and top positions?

    Hi there everyone I am finishing up another math game, and I was wondering if there was a quick way to subtract 30 from all of the objects on the forms top position, and 30 from their height attribute?

    Thank you so much!!!

  2. #2

    Thread Starter
    PowerPoster
    Join Date
    May 2006
    Posts
    2,295

    Re: Subtract 30 from all controls on form - their height and top positions?

    All of the objects are frames, labels, and shapes if that makes a difference?

  3. #3
    gibra
    Guest

    Re: Subtract 30 from all controls on form - their height and top positions?

    Cicle for each control in Me.Controls collection and change their values as you want.
    Last edited by gibra; Dec 8th, 2013 at 06:36 AM.

  4. #4

    Thread Starter
    PowerPoster
    Join Date
    May 2006
    Posts
    2,295

    Re: Subtract 30 from all controls on form - their height and top positions?

    Ok, lets say for ex I just wanted to subtract from 1 frame.

    Would I put

    Frame1.height = val(Frame1.height) - 30

    ???

  5. #5
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: Subtract 30 from all controls on form - their height and top positions?

    you do not need to use val() height is a numeric value and thus does not need converted

  6. #6
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Subtract 30 from all controls on form - their height and top positions?

    Calling Val() is almost always a weird choice anyway. It uses the "invariant locale" so depending on your regional settings it may not do what you expect. Of course that assumes you are using it to parse a String to a Double value... which is what it is for.

    In this case the height (which is Single) gets implicitly converted to a String because Val() needs a String argument, and then converted back to a Double (which Val() always returns).

    This could fail since implicit conversions are locale-aware while Val() uses the invariant locale.

    So it is both absurd and buggy to do this sort of thing.

  7. #7
    coder. Lord Orwell's Avatar
    Join Date
    Feb 2001
    Location
    Elberfeld, IN
    Posts
    7,621

    Re: Subtract 30 from all controls on form - their height and top positions?

    you could subtract just like you did there. In practice, if you are moving labels and stuff around, it's easier to have all their positions stored in an array and you simply loop through the array and change that and then call a sub that draws them on screen based on that array.
    My light show youtube page (it's made the news) www.youtube.com/@artnet2twinkly
    Contact me on the socials www.facebook.com/lordorwell

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