Solved

call function outside split loop

Posted on 2016-11-24
5
31 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 52

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 52

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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Suggested Solutions

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

740 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