while loop with multiple conditions

Posted on 2011-05-11
Last Modified: 2012-05-11
I am developing a VB application in which i have to check 2 conditions on while loop

while month(date1) <= month(date2) and year(date1) <= year(date2)
    date1 = dateadd("M",1,date1)
but it is checking only the first condition but not the second. is there any way where i can loop with 2 conditions
Question by:rajeeva_nagaraj
    LVL 59

    Accepted Solution

    That is your logic ... if you want both then use an or instead of and

    note as soon as date1 month is = or > that date 2 it will stop because false nd true = false

    while month(date1) <= month(date2) and year(date1) <= year(date2)
    while month(date1) <= month(date2) or year(date1) <= year(date2)


    Author Closing Comment

    Thanks a lot

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Hello again, all.  For those of you that have been following along, you'll know that this is my third article on this topic (though it is not Part III).  This article is sort of remedial, and probably the topic with which I should have started the s…
    I met Paul Devereux (@pdevereux) today when I responded to his tweet asking “Anybody know how to automate adding files from disk to a folder in #outlook  ?”.  I replied back and told Paul that using automation, in this case scripting, to add files t…
    This video discusses moving either the default database or any database to a new volume.
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    760 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

    8 Experts available now in Live!

    Get 1:1 Help Now