Code Bank
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingCode Bank

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old April 5th, 2004, 03:12 PM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
ASP Free God 14th Plane (11500 - 11999 posts)
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,760 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 5 h 22 m 16 sec
Reputation Power: 443
Functions

The following is just a list of functions that you can use to perform certain tasks through out your applications.

Calculate Age
This function will calculate a persons age based on the two
dates passed to it.

Code:
Function CalculateAge(Date1, Date2)
   bornDate = CDate(Date1)
   futureDate = CDate(Date2)
   
    if(Month(futureDate) < Month(bornDate) OR Month(futureDate) = Month(bornDate) AND Day(futureDate) < Day(bornDate)) Then
    	age = Year(futureDate) - Year(bornDate) - 1
	else
		age = Year(futureDate) - Year(bornDate)
	end if
	
	CalculateAge = age
End Function


Word Wrap Function
This function will print a certain number of characters per line of the string passed, depending on the integer value passed.
Code:
Function LineWrap(sString, iInterval)
	lFinalLen = Len(sString)
	Do Until lPos >= lFinalLen
		If iPosCounter = iInterval Then 
			iPosCounter = 0 
			
			For lBeginPos = lPos To 0 Step -1
				If Mid(sString, lBeginPos, 1) = Chr(32) Then Exit For
			Next 
			
			For lEndPos = lPos To lFinalLen
				If Mid(sString, lEndPos, 1) = Chr(32) Then Exit For
			Next 

			iWordLen = (lEndPos - 1) - (lBeginPos + 1)
			
			iWordPos = lPos - (lBeginPos + 1)
			
			dWrapThresh = iWordLen / 2
			If lEndPos > Len(sString) Then Exit Do
			If iWordPos >= dWrapThresh Then 
				sString = Left(sString, lEndPos) & "<br>" & Right(sString, lFinalLen - lEndPos)
			Else
				sString = Left(sString, lBeginPos) & "<br>" & Right(sString, lFinalLen - lBeginPos)
			End If
			lFinalLen = Len(sString)
		End If
		
		iPosCounter = iPosCounter + 1
		
		If lPos > 0 Then If Mid(sString, lPos, 2) = "<br>" Then iPosCounter = 0 
		lPos = lPos + 1
	Loop
	LineWrap = sString
End Function


Proper Case Function
This function will print a supplied string in Proper Case
The first letter of every word is capitalized

Code:
Function PCase(sValue)
	iPos = 1
	Do While InStr(iPos, sValue, " ", 1) <> 0
		iSpace = InStr(iPos, sValue, " ", 1)
		sTemp = sTemp & UCase(Mid(sValue, iPos, 1))
		sTemp = sTemp & LCase(Mid(sValue, iPos + 1, _
                      iSpace - iPos))
		iPos = iSpace + 1
	Loop

	sTemp = sTemp & UCase(Mid(sValue, iPos, 1))
	sTemp = sTemp & LCase(Mid(sValue, iPos + 1))

	PCase = sTemp
End Function

Feel free to private message me with any functions you might need and I will continue to update this thread.

Last edited by Memnoch : April 5th, 2004 at 03:14 PM.

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingCode Bank > Functions


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway