Looping Question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Stroumfs
    New Member
    • Mar 2007
    • 28

    Looping Question

    Hello all!

    I would like some help with the code below. I would like to write the following using a for loop. Can anyone help?

    frmResult.flgPr int.set_ColWidt h(0, 2800)
    frmResult.flgPr int.set_ColWidt h(2, 2800)
    frmResult.flgPr int.set_ColWidt h(4, 2800)
    frmResult.flgPr int.set_ColWidt h(6, 2800)
    frmResult.flgPr int.set_ColWidt h(8, 2800)

    Thanks
  • Denburt
    Recognized Expert Top Contributor
    • Mar 2007
    • 1356

    #2
    You didn't provide a lot of information here, but I will try to assist:


    Code:
    Do until Cnt = 2000
    frmResult.flgPrint.set_ColWidth(Cnt, 2800)
    Cnt = Cnt+2
    loop

    Comment

    • Killer42
      Recognized Expert Expert
      • Oct 2006
      • 8429

      #3
      Since you wanted a FOR loop, try this...
      Code:
      Dim I As Long
      For I = 0 To 8 Step 2
        frmResult.flgPrint.set_ColWidth([B]I[/B], 2800)
      Next

      Comment

      • Denburt
        Recognized Expert Top Contributor
        • Mar 2007
        • 1356

        #4
        Thank you Killer, I guess I need to be a bit more thorough when reading. :)

        Comment

        • vijaydiwakar
          Contributor
          • Feb 2007
          • 579

          #5
          Originally posted by Killer42
          Since you wanted a FOR loop, try this...
          Code:
          Dim I As Long
          For I = 0 To 8 Step 2
            frmResult.flgPrint.set_ColWidth([B]I[/B], 2800)
          Next
          for such a small loop use byte insted of long
          or u may try inline defination also
          (just for memory cunsumption purpose)
          take it easy

          Comment

          • Killer42
            Recognized Expert Expert
            • Oct 2006
            • 8429

            #6
            Originally posted by vijaydiwakar
            for such a small loop use byte insted of long
            or u may try inline defination also
            (just for memory consumption purpose)
            take it easy
            True, a Long uses three bytes more than a Byte variable. However, I always try to use Long wherever possible for performance reasons, as it's the native data type on a 32 bit processor.

            It's really just a matter of personal preference, I suppose.

            Comment

            Working...