Sunday, December 14, 2008
Sunday, October 26, 2008
Magician
Saturday, September 20, 2008
Wednesday, September 10, 2008
L
Saturday, September 6, 2008
Harry Potter
Monday, September 1, 2008
Useful code in VB2005 to lock input key
This code is written in the keypress event handler. It will lock the type of key. So, user won't type the restricted key(s), which is defined by the programmer.
Beside alphabet and digit, this code also available for keys like quotation, which will cause error for input into database by using SQL query.
Example code below means user only can input digit and plus symbol.
----------------------------------------------------------------------------------
Private Sub txtphone_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txttelp.KeyPress
If Not (Char.IsDigit(e.KeyChar) OrElse Char.IsControl(e.KeyChar)) AndAlso Not e.KeyChar = "+"c Then e.Handled = True
End Sub
----------------------------------------------------------------------------------
Try it yourself, it really works!!!
Beside alphabet and digit, this code also available for keys like quotation, which will cause error for input into database by using SQL query.
Example code below means user only can input digit and plus symbol.
----------------------------------------------------------------------------------
Private Sub txtphone_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txttelp.KeyPress
If Not (Char.IsDigit(e.KeyChar) OrElse Char.IsControl(e.KeyChar)) AndAlso Not e.KeyChar = "+"c Then e.Handled = True
End Sub
----------------------------------------------------------------------------------
Try it yourself, it really works!!!
Tuesday, August 26, 2008
Secret
Monday, August 25, 2008
Encrypt value
Some confidental information as password, mostly need to be encrypted. Here I have a simple coding in VB 2005. To decrypt, just need to make the same code with encrypt, then change to it's opposition code. If in encrypt using *2 (times 2), then in decrypt using /2 (divided by 2). Here is an example of encrypt code. Try it yourself...
----------------------------------------------------------------------------------
For i = 1 To Len(Password)
Result = Result & Chr(Asc(Mid(Password, i, 1)) * 2)
Next
----------------------------------------------------------------------------------
----------------------------------------------------------------------------------
For i = 1 To Len(Password)
Result = Result & Chr(Asc(Mid(Password, i, 1)) * 2)
Next
----------------------------------------------------------------------------------
Simple code to save n retrieve data from registry
Sometimes, we need to use registry to save some information of a system. That's better than using text file which can be removed easily by user. Here I have simple code in VB 2005 to make it. Just using SaveSetting and GetSetting. SaveSetting for save the value and GetSetting for retrieve the saved value.
Example:
SaveSetting "MySystem", "UserManagement", "Server", "Elini"
servername=GetSetting "MySystem", "UserManagement", "Server"
To see where the value is saved, follow steps below:
1. On the start menu, choose and open Run...
2. type regedit and click OK button
3. Open HKEY_CURRENT_USER -> Software -> VB and VBA Program Setting
4. There will have a folder MySystem -> User Management as set before in SaveSetting code
5. Open the folder and there will have variable name (in this case will be "Server") and the saved value.
Example:
SaveSetting "MySystem", "UserManagement", "Server", "Elini"
servername=GetSetting "MySystem", "UserManagement", "Server"
To see where the value is saved, follow steps below:
1. On the start menu, choose and open Run...
2. type regedit and click OK button
3. Open HKEY_CURRENT_USER -> Software -> VB and VBA Program Setting
4. There will have a folder MySystem -> User Management as set before in SaveSetting code
5. Open the folder and there will have variable name (in this case will be "Server") and the saved value.
Wednesday, June 4, 2008
I like drawing
One of my hobbies is drawing. I'm not expert, just like it...
See more of my drawing
Jay hip hop
Mary Chan
Pansy
Mostly i will draw Jay Chou. Because my elder sister is a big fan of jay chou.
So, I got lots of his pictures to draw.
Wednesday, April 30, 2008
Javascript for Credit Card Validity
I had a team project at school, making a website which need to input customer data to complete a business transaction.
The transaction needs customer credit card information and of course we must to check the validity of the card number for certain card type.
That's the problem, we didn't know how to make it.Then after I searched, I got information of how to make it and it really works. Fortunately it also helped us to add extra points in our website project.
What we did is just to add a javascript into the head section of webpage (page where user will input the credit card number). The javascript below only for checking 4 types of credit card.
Click this link to get the javascript code:
CardValidity
The transaction needs customer credit card information and of course we must to check the validity of the card number for certain card type.
That's the problem, we didn't know how to make it.Then after I searched, I got information of how to make it and it really works. Fortunately it also helped us to add extra points in our website project.
What we did is just to add a javascript into the head section of webpage (page where user will input the credit card number). The javascript below only for checking 4 types of credit card.
Click this link to get the javascript code:
CardValidity
Subscribe to:
Posts (Atom)