Solved

call function outside split loop

Posted on 2016-11-24
5
17 Views
Last Modified: 2016-11-29
Hi experts,

I need to get dates from weeknumber and weekday in a split loop, and use a function written by NightWizzard found on CodeProject. It works perfectly outside the loop, but called from within the loop it goes endless, and i have to reopen the browser to stop it.

Any ideas as how to access the function without this happening?

heres the function:

function WeekNrEval(wnr, td)
if wnr <= weeksthisyear then
thisweekstart = DateAdd("d", ((wnr) * 7), FirstWeekMonday)
thisweekdaydate = dateadd("d", td-1, thisweekstart)
WeekNrEval = thisweekdaydate
else

wnr = wnr - weeksthisyear
firstdateofyear = 1 &"/"& 1 &"/"& thisyear+1

firstfourthofyear = DateSerial(thisyear+1, 1, 4)
firstweekmonday = firstfourthofyear - WeekDay(firstfourthofyear, 0) + 1
thisweekstart = DateAdd("d", ((wnr) * 7), FirstWeekMonday)
thisweekdaydate = dateadd("d", td-1, thisweekstart)
WeekNrEval = thisweekdaydate
'response.Write(weeknr & " ugedage: " & weekdayname(weekday(thisweekdaydate)) & " " &  thisweekdaydate & "<br>")
end if

end function

Open in new window


and heres the code with splits and loops:

		weekinterval=Split(XLSweeks, "-")
			if ubound(weekinterval)> 0 then
			for weeknrs = weekinterval(0) to weekinterval(1)

				splitdays=Split(XLSdays, ";")
					for daynr = 0 to ubound(splitdays)
					dayname = splitdays(daynr)
					
							splitlocations=Split(XLSlocations, ";")
							for LocationCt = 0 to ubound(splitlocations)
							building = left(splitlocations(LocationCt), 4)
							localNr = right(splitlocations(LocationCt), 3)								
									
									if dayname = "mandag" then schday = 1
									if dayname = "tirsdag" then schday = 2
									if dayname = "onsdag" then schday = 3
									if dayname = "torsdag" then schday = 4
									if dayname = "fredag" then schday = 5
									if dayname = "lørdag" then schday = 6
									if dayname = "søndag" then schday = 7
										splitct = splitct+1
									
									response.Write(splitct&" "&WeekNrEval(weeknrs, schday)&" "&XLSname&" "&localnr&"<br>")

							next				
					
					next
			next

Open in new window


Hope this i sufficient information

Best regards
Morten B
0
Comment
Question by:MortenWB
  • 3
  • 2
5 Comments
 
LVL 49

Expert Comment

by:Ryan Chong
ID: 41900270
can you provide sample data for :
  • XLSweeks
  • XLSdays
  • XLSlocations
0
 

Author Comment

by:MortenWB
ID: 41900293
hi ryan,

thanks for replying,

yes:
examples could be

XLSweeks: 51-56 (notice that the code are meant to convert the weeknumbers exceeding the last week of the year to continue the next year starting with 1)
XLSdays: mandag;tirsdag
XLSlocations: 1584, 246;1584, 126

(the data are from an excel sheet)
0
 

Accepted Solution

by:
MortenWB earned 0 total points
ID: 41900637
Hi again,

I somehow found the solution, so I'll close the question.

Thanks for your attention.

Best regards
0
 
LVL 49

Expert Comment

by:Ryan Chong
ID: 41901047
Glad that you found the solution by yourself cheers
0
 

Author Closing Comment

by:MortenWB
ID: 41905459
I do not know what i did wrong when it did not work - typo's maybe, but now everything is up and running.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
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/…
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …
Need to grow your business through quality cloud solutions? With everything required to build a cloud platform and solution, you may feel like the distance between you and the cloud is quite long. Help is here. Spend some time learning about the Con…

914 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

20 Experts available now in Live!

Get 1:1 Help Now