Word 2003:How can I loop two integer variable to the sum of these two variable?

Posted on 2007-08-02
Last Modified: 2010-04-16
Is there a way to assign the value of an integer variable to another integer variable and then get the sum out of these two variables?  As in the follow do not added up right as desired in Word 2003:
varOne =0
for i = 1 to 3
next i
Question by:isischen
    LVL 59

    Expert Comment

    by:Chris Bottomley
    I must be missing something ... it works as coded, did you want it do something, or more correctly what were you expecting?

    LVL 59

    Expert Comment

    by:Chris Bottomley
    i.e. outputs are:
    2, (varone = 0 + vartwo = 2)
    4, (varone = 2 + vartwo = 2)
    6, (varone = 4 + vartwo = 2)


    Author Comment

    actually the calculation is not done in a For...Next loop.  I declared variables as arguments in the Function syntax and set variable to 0s and set up varOne=varOne+varTwo equation as statement.
    I want to pass the value of varOne to a second function for other calculation.  varTwo is a return from a method in the first function which is to be reused after looping thru procedures. I was hoping  varOne would be incremented.
    LVL 59

    Accepted Solution

    Then I suspect it is how the data is passed to the routine making the change.

    If a value is passed by value it can be accessed in the called routine but the original value is unchanged.  When passing the varone parameter try using the byref keyword i.e. sub2(byref varone as integer)


    Featured Post

    Live: Real-Time Solutions, Start Here

    Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    sumNumber challenge 16 81
    either24  challenge 19 73
    create an incrementing variable name AutoHotKey 5 33
    groovy example issue 10 37
    Purpose To explain how to place a textual stamp on a PDF document.  This is commonly referred to as an annotation, or possibly a watermark, but a watermark is generally different in that it is somewhat translucent.  Watermark’s may be text or graph…
    This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
    An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
    In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now