Results 1 to 3 of 3
  1. #1
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Odd use of VAL (WordXP et al.)

    <pre>strAr(UBound(strAr)) = LoadCellsToCommand(tbl, Val(lngTop), _
    Val(lngLeft), Val(lngHeight), Val(lngWidth), Val(lngGap))</pre>


    For design reasons my procedure LoadCellsToCommand needs its parameters ByRef; it loads controls to a GUI form, and adjusts the coordinate positions accordingly. I use the updated coordinates in the calling procedure to advance to the next position. Except in one case, where I want to lay out a set of controls in the first position.

    I've not used VAL to override ByRef before, only to coerce a string value to a numeric value. I can't recall ever seeing this in code samples. I'm rarely the first to do anything. Is there a better way of doing this?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Odd use of VAL (WordXP et al.)

    You can also force an argument to be ByVal by enclosing it in parentheses:

    strAr(UBound(strAr)) = LoadCellsToCommand(tbl, (lngTop), (lngLeft), (lngHeight), (lngWidth), (lngGap))

  3. #3
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Odd use of VAL (WordXP et al.)

    > enclosing it in parentheses ...
    ... which effectively forces it to be an evaluated expression. Of course! Why didn't I think of that!

Posting Permissions

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