Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Problem with for statement

Posted on 2004-04-29
14
Medium Priority
?
317 Views
Last Modified: 2010-05-18
           for i=0 to UBound(array,2)  ' Go Up to Down in array (column)
                 for j=0 to UBound(array,1) ' Go left to right in array (row)
                             If ((j <> 0) OR (j <> 3)) Then
                                    objSpreadsheet.Cells(i + 2,j + 1).Value = array(j,i)
                              End If
                 next
            Next

This doesn't work.  The OR portion is what is not working.  If I use one parameter, it works fine and skips that value in the array:

            for i=0 to UBound(array,2)  ' Go Up to Down in array (column)
                 for j=0 to UBound(array,1) ' Go left to right in array (row)
                             If j <> 3 Then
                                    objSpreadsheet.Cells(i + 2,j + 1).Value = array(j,i)
                              End If
                 next
            Next
0
Comment
Question by:dba123
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 7
14 Comments
 
LVL 10

Accepted Solution

by:
Shailesh15 earned 2000 total points
ID: 10952214
Try...

 for i=0 to UBound(array,2)  ' Go Up to Down in array (column)
               for j=0 to UBound(array,1) ' Go left to right in array (row)
                         If ((j <> 0) AND (j <> 3)) Then
                              objSpreadsheet.Cells(i + 2,j + 1).Value = array(j,i)
                         End If
               next
          Next
0
 
LVL 1

Author Comment

by:dba123
ID: 10952268
thanks, I should have tried that
0
 
LVL 1

Author Comment

by:dba123
ID: 10952406
what about this one

            for ((i=0 to UBound(array,2)) AND (a=0 to Ubound(array,2)))  ' Go Up to Down in array (column)
                 for ((j=0 to UBound(array,1)) AND ((b=0 to Ubound(array,2))) ' Go left to right in array (row)
                             If ((b <> 0) AND (b <> 3)) Then
                                    objSpreadsheet.Cells(i + 2,j + 1).Value = array(b,a)
                              End If
                 next
            Next

giving me error:

Expected identifier

for ((i=0 to UBound(array,2)) AND (a=0 to Ubound(array,2)))
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 10

Expert Comment

by:Shailesh15
ID: 10952429
It's not possible to have condition like that...:(

What are you trying to do? Can't you use same i , j for a, b?
0
 
LVL 1

Author Comment

by:dba123
ID: 10952451
basically, I can't use j and i for both the spreadsheet cells and the array.  Because the spreadsheet cell columns are off if I skip j when I used j in the array (shown at the very top in my initial post)

So I am only wanting to skip the array value if the array value is 0 or 3, not the spreadsheet cell so that is why I used another pair of variables for the array..so I can just check for 0 or 3 just for the array.....the spreadsheet should remain using the j and i as is.
0
 
LVL 10

Expert Comment

by:Shailesh15
ID: 10952615
Try this..

    for a=0 to Ubound(array,2)  ' Go Up to Down in array (column)
               for b=0 to Ubound(array,2) ' Go left to right in array (row)
                         If ((b <> 0) AND (b <> 3)) Then
                              objSpreadsheet.Cells(i + 2,j + 1).Value = array(b,a)
                 
                              j=j+1
                         End If
                next
             i=i+1
         Next
0
 
LVL 10

Expert Comment

by:Shailesh15
ID: 10952695
you may need to change  

for b=0 to Ubound(array,2)

to  

for b=0 to Ubound(array,1) ...
0
 
LVL 1

Author Comment

by:dba123
ID: 10952716
     j=0
      i=0

    for a=0 to Ubound(array,2)  ' Go Up to Down in array (column)
               for b=0 to Ubound(array,2) ' Go left to right in array (row)
                         If ((b <> 0) AND (b <> 3)) Then
                              objSpreadsheet.Cells(i + 2,j + 1).Value = array(b,a)

                              j=j+1
                         End If
                next
             i=i+1
         Next
         
      End If


I get an error, I think because of where I set the initial value for the i and j variables

Microsoft Office Web Components 9.0 error 'e004002a'
0
 
LVL 1

Author Comment

by:dba123
ID: 10952743
I changed the Ubound from 2 to 1, just that you don't see it in my post above
0
 
LVL 10

Expert Comment

by:Shailesh15
ID: 10952762
Couple of bugfixes before you findout yourself!


for i=0 to UBound(array1,2)  ' Go Up to Down in array (column)
               for j=0 to UBound(array1,1) ' Go left to right in array (row)
                         If ((j <> 0) AND (j <> 3)) Then
                               objSpreadsheet.Cells(i + 2,j + 1).Value = array(b,a)
                             
                              j=j+1
                         End If
               next
               j=0
               i=+1
          Next
0
 
LVL 1

Author Comment

by:dba123
ID: 10952805
Here it is

    for a=0 to Ubound(array,2)  ' Go Up to Down in array (column)
          j=0
               for b=0 to Ubound(array,1) ' Go left to right in array (row)
                           i=0
                         If ((b <> 0) AND (b <> 3)) Then
                              objSpreadsheet.Cells(i + 2,j + 1).Value = array(b,a)
                              j=j+1
                         End If
                next
             i=i+1
         Next

      End If
0
 
LVL 1

Author Comment

by:dba123
ID: 10952806
thanks much!!!
0
 
LVL 10

Expert Comment

by:Shailesh15
ID: 10952816
Looks ok... Are you still getting that error?
0
 
LVL 10

Expert Comment

by:Shailesh15
ID: 10952818
Ok I didn't see your post
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

730 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