Solved

call function outside split loop

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

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 51

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Classic ASP, Search Recordset on pick list change 1 71
Need help editing script 3 80
Error viewing ASP page 12 174
Change visitor's REMOTE_ADDR to server's REMOTE_ADDR 2 38
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…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

831 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