ASP equivalent to PHP Ucfirst function

This code does the same thing that Ucfirst function makes in PHP. “Ucfirst” means “Uppercase first letter”. ASP doesn’t have…

November 10, 2009

This code does the same thing that Ucfirst function makes in PHP. “Ucfirst” means “Uppercase first letter”. ASP doesn’t have this function natively:

function ucfirst(tname)
	ucfirst = ""
	tname = tname & " "
	do while instr(tname, " ")
		temp_string = left(tname, instr(tname," " ) -1)
		' ucase the first letter
		ucfirst = ucfirst & ucase(mid(temp_string, 1,1))
		' lcase for rest of word
		ucfirst = ucfirst & lcase(mid(temp_string,2)) & " "
		tname = right(tname, len(tname) - instr(tname," " ))
	loop
	'show me what i get
	ucfirst = ucfirst & ucase(mid(tname, 1,1))
	ucfirst = ucfirst & mid(tname,2)
	ucfirst = Trim(ucfirst)
end Function

Author

I'm a software engineer, an everyday web developer and a maker. I usually build sites with PHP, within or without WordPress. I build Internet of Things with Arduino and ESP8266. I'm the founder of Rockit.it and Dailybest.it and I'm actually the Chief Technical Officer of Better Days web agency.

Recommended

ASP equivalent to PHP strip_tags

I’ve found those functions around in the internet and I put them here just to remind how to strip tags…

February 9, 2010

ASP equivalent to PHP ereg_replace function

I’ve used so many time the php function ereg_replace that when I have to use ASP (’cause sometimens you have…

November 10, 2009

WP doesn’t send email? try this

Snippets for sending emails with Wordpress

February 8, 2020

Highlight text for search results in PHP

Useful code to highlight text occurences in search results or in a text. How to highlight text in a string…

September 2, 2016

How to add rel=”nofollow” to links with preg_replace()

Adding rel="nofollow" to external link is a good SEO practice.

September 22, 2015

Limit the number of categories for posts in WordPress

CHOOSE ONLY ONE CATEGORY WORDPRESS If you need to limit the number of categories used by the authors of your…

September 14, 2015