Quantcast
Viewing all articles
Browse latest Browse all 20

Looping Problem

Hi,

 

Try something like this and please read my code comments.

 

 

 

 

Regards,

 

John

 

 

Code Block

 

 

Public

Class Form1

 

PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

 

'Set a DATE.

Dim myDate AsDate = Now

Dim loopCount_NumberOfDays AsInteger = 0

Dim outputString AsString = ""

Do

SelectCase myDate.DayOfWeek

Case DayOfWeek.Monday To DayOfWeek.Friday

outputString &= myDate.ToShortDateString & vbCrLf

'Do your calculations here.>>

 

 

 

 

'Add one to the current date.

myDate = myDate.AddDays(1)

loopCount_NumberOfDays += 1

Case DayOfWeek.Saturday

'Add 1 day if it is a Saturday to show the Sunday message!!

myDate = myDate.AddDays(1)

loopCount_NumberOfDays += 1

outputString &= "**** Saturday skipped!! ****"& vbCrLf

Case DayOfWeek.Sunday

'Add 1 day if it is a Sunday.

myDate = myDate.AddDays(1)

loopCount_NumberOfDays += 1

outputString &=

"**** Sunday skipped!! ****"& vbCrLf

EndSelect

'Loop for 14 days in total.

LoopUntil loopCount_NumberOfDays = 14

MessageBox.Show(outputString)

MessageBox.Show(

"Loop ran for "& loopCount_NumberOfDays.ToString & " days.")

EndSub

End

Class

 

 


Viewing all articles
Browse latest Browse all 20

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>