Solved

call function outside split loop

Posted on 2016-11-24
5
12 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
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 seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

757 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

21 Experts available now in Live!

Get 1:1 Help Now