Consulting

Results 1 to 6 of 6

Thread: Haven't encountered this before, what does it mean?

  1. #1
    VBAX Newbie
    Joined
    Dec 2022
    Location
    Houston, TX, USA
    Posts
    2
    Location

    Haven't encountered this before, what does it mean?

    Trying to modify someone else's code:

    Set ReturnArray = Application.InputBox("Select an area consisting of 3-rows and " & n3 - (n3 = 1) & _
    " columns" & Chr(13) & "to report results.",

    I don't get the n3 - (n3=1) part. What is it doing?

    Thanks!

  2. #2
    VBAX Regular
    Joined
    May 2018
    Location
    Sydney
    Posts
    57
    Location
    This line of code could be asking the user to select an area consisting of 3 rows and n3-1 columns. n3 could be a variable that is defined elsewhere in the code and is likely the number of columns in the area that the user is selecting. The (n3=1) part might be a condition which, if true, will subtract 1 from the number of columns and display it as the second part of the prompt.
    If you only ever do what you can , you'll only ever be what you are.

  3. #3
    VBAX Newbie
    Joined
    Dec 2022
    Location
    Houston, TX, USA
    Posts
    2
    Location
    Quote Originally Posted by Grade4.2 View Post
    This line of code could be asking the user to select an area consisting of 3 rows and n3-1 columns. n3 could be a variable that is defined elsewhere in the code and is likely the number of columns in the area that the user is selecting. The (n3=1) part might be a condition which, if true, will subtract 1 from the number of columns and display it as the second part of the prompt.
    The (n3=1) subtracting one if n3=1 makes perfect sense from what the code is trying to do.

    I haven't found this putting an equation inside parentheses documented anywhere. Where can I read up on it?

    Thanks!

  4. #4
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,728
    Location
    I haven't found this putting an equation inside parentheses documented anywhere. Where can I read up on it?

    Thanks!
    Not much to read up on

    Sub demo()    Dim n3 As Long
        
        n3 = 1
        
        MsgBox n3               '   1
        MsgBox n3 = 1           '   True
        MsgBox CLng(n3 = 1)     '   -1
        MsgBox CLng(True)       '   -1
        MsgBox n3 - (n3 = 1)    '   2
    End Sub
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  5. #5
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,059
    Location
    So why not simply write

    Set ReturnArray = Application.InputBox("Select an area consisting of 3-rows and " & 2 & _
    " columns" & Chr(13) & "to report results."
    rather than

    Set ReturnArray = Application.InputBox("Select an area consisting of 3-rows and " & n3 - (n3 = 1) & _
    " columns" & Chr(13) & "to report results.",
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  6. #6
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    Presumably, the value of n3 is not hard coded by the programmer
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

Posting Permissions

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