Results 1 to 8 of 8
  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

    Loop in Immediate window (Word97SR2/VBE)

    <pre> for i = 1 to 10 rint asc(mid(strresult,i,1)): next i
    </pre>


    My VBA code produces a string result strResult.

    I'd like to display the ascii values of each of its ten characters in the Immediate Window.

    The construct above doesn't work, and I can't see any way of accomplishing it.

    Anyone? Kevin?!!???



    ... and yes,

    <pre>for i = 1 to Len(strresult) rint asc(mid(strresult,i,1)): next i
    </pre>

    would be preferable

  2. #2
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Loop in Immediate window (Word97SR2/VBE)

    How about :
    for i = 1 to Len(strresult) :Debug.print asc(mid(strresult,i,1)): next i
    Francois

  3. #3
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Dublin, Ireland, Republic of
    Posts
    2,697
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Loop in Immediate window (Word97SR2/VBE)

    I think if you want your loop to operate in the immediate window, you also need to to assign the value to the variable in the immediate window, by either calling the function in your code or a direct assignment.

    If your code that produces the string result is MyFunction, then something like

    strresult = MyFunction():for i = 1 to len(strresult) rint asc(mid(strresult,i,1)): next i

    just might work

    Andrew C

  4. #4
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Loop in Immediate window (Word97SR2/VBE)

    I'd say Frank nailed it.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

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

    Re: Loop in Immediate window (Word97SR2/VBE)

    > for i = 1 to Len(strresult) ebug.print asc(mid(strresult,i,1));: next i

    Excellent, thank you. I felt sure there was a way.

    Incidentally, it works even 'though I have "Option Explicit" in each module.

    I took the liberty of inserting a semi-colon before the ultimate colon. That lists my ascii codes horizontally on one line of output.

  6. #6
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Loop in Immediate window (Word97SR2/VBE)

    As long as the assignment statement proceeds the loop in the immediate window, he should be alright:

    strResult = "123456789"

    for i = 1 to ....


    Isn't interpretive BASIC wonderful? Notice how Chris used the semicolon on the Debug.print line in his recent post. That goes back to the earliest eprom BASIC installed on every IBM PC until ???
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  7. #7
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Loop in Immediate window (Word97SR2/VBE)

    <hr>Isn't interpretive BASIC wonderful? Notice how Chris used the semicolon on the Debug.print line in his recent post. That goes back to the earliest eprom BASIC installed on every IBM PC until ???<hr>
    And before that, on the Radio Shak's TRS-80 Model 1 (1979 if iremember well)
    Francois

  8. #8
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Loop in Immediate window (Word97SR2/VBE)

    Good show. Quite right. I learned to program on a Model I with 4k of RAM. At great personal sacrifice I upgraded the unit (which did not belong to me) to 16k for, as I recall, $139.00. I later upgraded to a Model III with -- get this -- dual disk drives!

    You remember well.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

Posting Permissions

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