Thursday, November 05, 2009

How to add a combo box to an excel?

Today I tried something new.. How to add a combo box to an excel, whose values come from some range in the sheet. So here you go..
I am using EXCEL 2002. Go to the menu.. View >> Toolbars >> FormsDrag and drop the combo box on the sheet. Rt click the combo box and select "Format Control" property and in the "Input Range" select the range where the values which you want to appear on the combo box exits. This can be a region on the same sheet or on a different sheet. Here I have selected the first row of Sheet2 "Sheet2!$A$1:$A$34"
Click the combobox and you can see the values are populated!

Thursday, October 29, 2009

ORACLE query which returns all table names which contains a particular field.

The following ORACLE query returns all table names which contains the column 'EMPLOYEE_ID'.
SELECT * FROM ALL_TAB_COLUMNS C, ALL_OBJECTS O
WHERE C.TABLE_NAME = O.OBJECT_NAME
AND C.OWNER = O.OWNER
AND O.OBJECT_TYPE = 'TABLE'
AND COLUMN_NAME LIKE 'EMPLOYEE_ID'
AND C.OWNER = 'YOUR_SCHEMA_NAME'
AND TABLE_NAME NOT LIKE 'BIN%'
PS: Replace YOUR_SCHEMA_NAME with the name of your DB schema.

Sunday, February 25, 2007

Internet Anagram Server

Found a good site today which rearranges the characters in a word that you input.
Actually it was there in my mind to make a windows application which does this, so before starting to work on it thought it would be better to search on the net whether some one had made this before and ended up on this site.
http://wordsmith.org/anagram/

Wednesday, January 24, 2007

Using a Regular Expression in the Code Behind page

I searched google for something like this but didn't find any...
So am posting the one which I made here..

Function IsValidEmail(ByVal strEmail As String) As Boolean
Dim RegExp As New Regex("\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*")
Return RegExp.IsMatch(strEmail)
End Function

Now on the respective event call the function like this..

Dim boolValid As Boolean
boolValid = IsValidEmail("rajesh@nurture3.com")
Response.Write(boolValid)

Cheers
Rajesh Sivaraman.

Tuesday, December 12, 2006

Function which returns the "Selected Texts" of a multiselect listbox

Function ReturnSelectedTexts(ByVal objControlName As Object) As String
'This function returns the selected texts of the multiselect listbox
Dim strSelectedTexts As String
Dim lstItem As ListItem
For Each lstItem In objControlName.items
If lstItem.Selected = True Then
strSelectedTexts = strSelectedTexts & lstItem.Text & ", "
End If
Next
strSelectedTexts = Trim(strSelectedTexts)
strSelectedTexts = Left(strSelectedTexts, Len(strSelectedTexts) - 1)
Return strSelectedTexts
End Function

'----Usage
lblSearchCriterias.Text = "Email verified: " & ReturnSelectedTexts(lstEmailVerified)

'--It will give the selected items as comma separated.

Cheers
Rajesh Sivaraman.

Sunday, December 10, 2006

Disallow some characters in a string...

function disallowCharacters(strText)
{
//The parameter to the function is the string which is to be validated
//The variable "strNotAllowed" below this line should contain the characters
// which are not allowed in the string
var strNotAllowed = ";:/\,&\\";
var checkStr = strText;
var allValid = true;
for (i = 0; i < strNotAllowed.length; i++)
{
if (strText.indexOf(strNotAllowed.charAt(i)) > 0)
{
allValid = false;
}
}
return allValid;
}

//----------------------------------
//how to use

if (document.Form1.txtemail.value!="")
{
//alert(disallowCharacters(document.Form1.txtemail.value));
if (!disallowCharacters(document.Form1.txtemail.value))
{
//alert('Invalid Character');
alert("Please enter a valid Email Address");
document.Form1.txtemail.focus();
return false;
}
else
{
bemail1=new RegExp(/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/);
bemail2 = bemail1.exec(document.Form1.txtemail.value);

if(!bemail2)
{
alert("Please enter a valid Email Address");
document.Form1.txtemail.focus();
return false;
}
}
}

Function which allows only integers...

function IsInteger(varInt)
{
var checkOK = "0123456789";
var checkStr = varInt;
var allValid = true;
var allNum = "";
for (i = 0; i < checkStr.length; i++)
{
ch = checkStr.charAt(i);
for (j = 0; j < checkOK.length; j++)
if (ch == checkOK.charAt(j))
break;
if (j == checkOK.length)
{
allValid = false;
break;
}
if (ch != ",")
allNum += ch;
}
return allValid;
}

//--------------------

//how to use

if (document.Form1.txtMainTelephone.value!="")
{
if (!IsInteger(document.Form1.txtMainTelephone.value))
{
alert("Invalid character entered in main telephone number!\nPlease enter only numbers.");
document.Form1.txtMainTelephone.focus();
return false;
}
}