Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6993067
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:43:00+00:00 2026-05-27T19:43:00+00:00

[Part 1 – Original question] I have values like 30, 31, 28 or 29

  • 0

[Part 1 - Original question]

I have values like 30, 31, 28 or 29 which are total days of the month.

I want to make a for loop

If I select 28 it should display a msgbox 28 times.

If I select 31 it should display a msgbox 31 times.

The code I tried:

Dim dayst As Variant
Dim tot1 As Variant
tot1 = DateDiff("d", "01/2011", DateAdd("m", 1, "01/2011"))
tot1 = Split(tot1, ",")
For Each dayst In tot1
   MsgBox dayst
Next

The above code is showing “31” in the msgbox, instead of 31 times like “1”, “2”, … “31”

I want to display a msgbox 31 times incrementing from 1 to 31.

[Part 2 - Updated request]

Default Column Value Example

ID 1 2 ..... 31  totaldays

001 Yes Yes .... Yes 31
002 Yes Yes .... Yes 31
003 Yes Yes .... Yes 31
.....

001 is coming from table
Yes is the default column value for 1 to 31 or 1 to 28
totaldays should be no of days permonth.

How can I accomplish this using vb6.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T19:43:01+00:00Added an answer on May 27, 2026 at 7:43 pm

    You could just use a simple loop like this – although I dont see why you would want to have 28-31 MsgBox prompts in a row

    Dim tot1 As Long
    Dim lngDays As Long
    tot1 = DateDiff("d", "01/2011", DateAdd("m", 1, "01/2011"))
    For lngDays = 1 To tot1
        MsgBox lngDays
    Next
    

    Updated version - adds early exit option

    Dim tot1 As Long
    Dim lngDays As Long
    Dim lngExit As Long
    tot1 = DateDiff("d", "01/2011", DateAdd("m", 1, "01/2011"))
    For lngDays = 1 To tot1
       lngExit = MsgBox(lngDays, vbOKCancel, "Press Cancel to exit")
       If lngExit = vbCancel Then Exit Sub
    Next
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Part of a new product I have been assigned to work on involves server-side
Part of our product is an IE plugin (BHO), which is running happily in
Part of the code: ...where se.DateFrom >= pDateFrom && se.DateTo <= pDateTo select se...
Part of a simple skeleton utility I'm hacking on I have a grammar for
Part of my script is taking values and putting them to a text file
Part of what I want to offer subscribers to my application is a map
Part 1: I have a call to layout(:default){|path,wish| wish !~ /rss|atom|json/} but requests to
Part of my project directory structure looks like: \projects\project\main.R \projects\project\src where \src contains a
Part of an application I'm writing allows for users to upload images which I
Part of asking a question on SO is typing tags. When you type a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.