Search This Blog
Popular Posts
- List of KeyAscii in VB6.0
- List of VB Keycode in Visual Basic 6.0
- Enable and Disable Button VB6 code
- Check valid Email Address in PHP code
- Clear Textbox when Onclick HTML Javascript code
- Get the Filename and the extension of Filename Visual Basic 6.0
- Disable Right-Click of Website - HTML code
- Latest Plate Number with barcode in the Philippines
Count how many characters in Text Area in HTML code
In HTML code
<form name="count_form" method="post" action="">
<textarea name="desc" cols="40" rows="7" id="desc"
onKeyDown="CountWordsLeft(count_form, document.count_form.desc, document.count_form.count,100);"
onKeyUp="CountWordsLeft(count_form, document.count_form.desc, document.count_form.count,100);"
onPaste="CountWordsLeft(count_form, document.count_form.desc, document.count_form.count,100);">
</textarea>
<input readonly name="count" type="text" size="5" value="100">
</form>
--- In Javascript
function CountWordsLeft(myForm, field, count, no_words) {
var text=field.value + " ";
if(no_words>0)
{
var iwhitespace = /^[^A-Za-z0-9]+/gi; // remove initial whitespace
var left_trimmedStr = text.replace(iwhitespace, "");
var na = rExp = /[^A-Za-z0-9]+/gi; // non alphanumeric characters
var cleanedStr = left_trimmedStr.replace(na, " ");
var splitString = cleanedStr.split(" ");
var word_count = splitString.length -1;
count.value=no_words-word_count;
}
}
Get the Filename and the extension of Filename Visual Basic 6.0
Public Function getextension(filename As String) As String
For i = Len(filename) To 2 Step -1
c = Mid(filename, i, 1)
If c = "." Then
pos = i + 1
End If
Next
getextension = Mid(filename, pos, (Len(filename) + 1 - pos))
End Function
'Function to get filetitle from full path
Public Function getfiletitle(filename As String) As String
For i = Len(filename) To 2 Step -1
c = Mid(filename, i, 1)
If c = "\" Then
pos = i + 1
End If
Next
getfiletitle = Mid(filename, pos, (Len(filename) + 1 - pos))
End Function
List of KeyAscii in VB6.0
Key Codes
=========
Constant Value Description
vbKeyLButton 1 Left mouse button
vbKeyRButton 2 Right mouse button
vbKeyCancel 3 CANCEL key
vbKeyMButton 4 Middle mouse button
vbKeyBack 8 BACKSPACE key
vbKeyTab 9 TAB key
vbKeyClear 12 CLEAR key
vbKeyReturn 13 ENTER key
vbKeyShift 16 SHIFT key
vbKeyControl 17 CTRL key
vbKeyMenu 18 MENU key
vbKeyPause 19 PAUSE key
vbKeyCapital 20 CAPS lock key
vbKeyEscape 27 ESC key
vbKeySpace 32 SPACEBAR key
vbKeyPageUp 33 PAGE UP key
vbKeyPageDown 34 PAGE DOWN key
vbKeyEnd 35 END key
vbKeyHome 36 HOME key
vbKeyLeft 37 LEFT ARROW key
vbKeyUp 38 UP ARROW key
vbKeyRight 39 RIGHT ARROW key
vbKeyDown 40 DOWN ARROW key
vbKeySelect 41 SELECT key
vbKeyPrint 42 print SCREEN key
vbKeyExecute 43 EXECUTE key
vbKeySnapshot 44 SNAPSHOT key
vbKeyInsert 45 INS key
vbKeyDelete 46 DEL key
vbKeyHelp 47 HELP key
vbKeyNumlock 144 NUM lock key
KeyA Through KeyZ Are the Same as Their ASCII Equivalents: 'A' Through 'Z'
==========================================================================
Constant Value Description
vbKeyA 65 A key
vbKeyB 66 B key
vbKeyC 67 C key
vbKeyD 68 D key
vbKeyE 69 E key
vbKeyF 70 F key
vbKeyG 71 G key
vbKeyH 72 H key
vbKeyI 73 I key
vbKeyJ 74 J key
vbKeyK 75 K key
vbKeyL 76 L key
vbKeyM 77 M key
vbKeyN 78 N key
vbKeyO 79 O key
vbKeyP 80 P key
vbKeyQ 81 Q key
vbKeyR 82 R key
vbKeyS 83 S key
vbKeyT 84 T key
vbKeyU 85 U key
vbKeyV 86 V key
vbKeyW 87 W key
vbKeyX 88 X key
vbKeyY 89 Y key
vbKeyZ 90 Z key
Key0 Through Key9 Are the Same as Their ASCII Equivalents: '0' Through '9
=========================================================================
Constant Value Description
vbKey0 48 0 key
vbKey1 49 1 key
vbKey2 50 2 key
vbKey3 51 3 key
vbKey4 52 4 key
vbKey5 53 5 key
vbKey6 54 6 key
vbKey7 55 7 key
vbKey8 56 8 key
vbKey9 57 9 key
Keys on the Numeric Keypad
==========================
Constant Value Description
vbKeyNumpad0 96 0 key
vbKeyNumpad1 97 1 key
vbKeyNumpad2 98 2 key
vbKeyNumpad3 99 3 key
vbKeyNumpad4 100 4 key
vbKeyNumpad5 101 5 key
vbKeyNumpad6 102 6 key
vbKeyNumpad7 103 7 key
vbKeyNumpad8 104 8 key
vbKeyNumpad9 105 9 key
vbKeyMultiply 106 MULTIPLICATION SIGN (*) key
vbKeyAdd 107 PLUS SIGN (+) key
vbKeySeparator 108 ENTER (keypad) key
vbKeySubtract 109 MINUS SIGN (-) key
vbKeyDecimal 110 DECIMAL POINT(.) key
vbKeyDivide 111 DIVISION SIGN (/) key
Function Keys
=============
Constant Value Description
vbKeyF1 112 F1 key
vbKeyF2 113 F2 key
vbKeyF3 114 F3 key
vbKeyF4 115 F4 key
vbKeyF5 116 F5 key
vbKeyF6 117 F6 key
vbKeyF7 118 F7 key
vbKeyF8 119 F8 key
vbKeyF9 120 F9 key
vbKeyF10 121 F10 key
vbKeyF11 122 F11 key
vbKeyF12 123 F12 key
vbKeyF13 124 F13 key
vbKeyF14 125 F14 key
vbKeyF15 126 F15 key
vbKeyF16 127 F16 key
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
MsgBox KeyCode
End Sub
List of VB Keycode in Visual Basic 6.0
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
'make sure KeyPreview is True on Form Properties
On Error Resume Next
Select Case KeyCode
Case vbKey 'Then Find which key you want to use from the list below
'Code to run when key is pressed
End Select
End Sub
vbKeyLButton Left Mouse Button
vbKeyRButton Right Mouse Button
vnKeyCancel Cancel Key
vbKeyMButton Middle Mouse button
vbKeyBack Back Space Key
vbKeyTab Tab Key
vbKeyClear Clear Key
vbKeyReturn Enter Key
vbKeyShift Shift Key
vbKeyControl Ctrl Key
vbKeyMenu Menu Key
vbKeyPause Pause Key
vbKeyCapital Caps Lock Key
vbKeyEscape Escape Key
vbKeySpace Spacebar Key
vbKeyPageUp Page Up Key
vbKeyPageDown Page Down Key
vbKeyEnd End Key
vbKeyHome Home Key
vbKeyLeft Left Arrow Key
vbKeyUp Up Arrow Key
vbKeyRight Right Arrow Key
vbKeyDown Down Arrow Key
vbKeySelect Select Key
vbKeyPrint Print Screen Key
vbKeyExecute Execute Key
vbKeySnapshot Snapshot Key
vbKeyInsert Insert Key
vbKeyDelete Delete Key
vbKeyHelp Help Key
vbKeyNumlock Delete Key
vbKeyA through vbKeyZ are the key code constants for the alphabet
vbKey0 through vbKey9 are the key code constants for numbers
vbKeyF1 through vbKeyF16 are the key code constants for the function keys
vbKeyNumpad0 through vbKeyNumpad9 are the key code constants for the numeric key pad
Math signs are:
vbKeyMultiply - Multiplication Sign (*)
vbKeyAdd - Addition Sign (+)
vbKeySubtract - Minus Sign (-)
vbKeyDecimal - Decimal Point (.)
vbKeyDivide - Division sign (/)
vbKeySeparator - Enter (keypad) sign
Check valid Email Address in PHP code
function validate_email($email)
{
// Create the syntactical validation regular expression
$regexp = "^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,4})$";
// Presume that the email is invalid
$valid = 0;
// Validate the syntax
if (eregi($regexp, $email))
{
list($username,$domaintld) = split("@",$email);
// Validate the domain
if (getmxrr($domaintld,$mxrecords))
$valid = 1;
} else {
$valid = 0;
}
return $valid;
}
Disable Right-Click of Website - HTML code
<html>
<head>
<script>
var isNS = (navigator.appName == "Netscape") ? 1 : 0;
if(navigator.appName == "Netscape") document.captureEvents(Event.MOUSEDOWN||Event.MOUSEUP);
function mischandler(){
return false;
}
function mousehandler(e){
var myevent = (isNS) ? e : event;
var eventbutton = (isNS) ? myevent.which : myevent.button;
if((eventbutton==2)||(eventbutton==3)) return false;
}
document.oncontextmenu = mischandler;
document.onmousedown = mousehandler;
document.onmouseup = mousehandler;
</script>
</head>
<body>
right click disabled
</body>
</html>
Enable and Disable Button VB6 code
There are times when it is desirable to disable the
close button on a form. EnableCloseButton() is a simple function that
does just this, and can re-enable the button as well.
Ordinarily it is quite a simple matter to disable a menu item, but VB
does not like us doing this to a form's close button. As a result more
work is required to trick VB into thinking that the close option no
longer exists if we are to disable the button. This is all hidden from
the developer in one simple function.
For example, to disable a form's close button on loading:
For example, to disable a form's close button on loading:
And to re-enable it later:
- PrivateSub Form_Load()
- EnableCloseButton me.hWnd, false
- End Sub
- private Sub Command1_Click()
- EnableCloseButton me.hWnd, true
- End Sub
Clear Textbox when Onclick HTML Javascript code
<html><head><title>password</title>
<script type = "text/javascript">
onload = function()
{
var pStyle = document.getElementsByName('passwd')[0].style
pStyle.backgroundColor="transparent";
pStyle.backgroundImage="url(pass.gif)";
pStyle.backgroundRepeat="no-repeat";
}
</script>
</head>
<body>
<form>
<input name="passwd" type="password"
onfocus="this.style.backgroundImage='';"/>
</form>
</body></html>
<script type = "text/javascript">
onload = function()
{
var pStyle = document.getElementsByName('passwd')[0].style
pStyle.backgroundColor="transparent";
pStyle.backgroundImage="url(pass.gif)";
pStyle.backgroundRepeat="no-repeat";
}
</script>
</head>
<body>
<form>
<input name="passwd" type="password"
onfocus="this.style.backgroundImage='';"/>
</form>
</body></html>
UCase on the first letter 'Together they created TCase code for ASP
stringText = "this IS a TeStT OF sTuff !"
response.write "<B>This is the original string:</b> '" & stringText & "'<BR><BR><BR>"
' TCase code
Function TCase(stringText)
stringText = Trim(stringText)
stringTextLCASE = lcase(stringText)
stringTextSplit = split(stringTextLCASE, " ")
stringTextoutput = ""
for each i in stringTextSplit
'stringTextoutput = stringTextoutput & replace(i, left(i,1), Ucase(left(i,1))) & " "
titlecaseletter = ucase(left(i,1))
xcount = len(i) - 1
titleword = right(i,xcount)
stringTextoutput = stringTextoutput & " " & titlecaseletter & titleword
Next
TCase = stringTextoutput
end function
'text output
response.write TCase(stringText)
response.write "<B>This is the original string:</b> '" & stringText & "'<BR><BR><BR>"
' TCase code
Function TCase(stringText)
stringText = Trim(stringText)
stringTextLCASE = lcase(stringText)
stringTextSplit = split(stringTextLCASE, " ")
stringTextoutput = ""
for each i in stringTextSplit
'stringTextoutput = stringTextoutput & replace(i, left(i,1), Ucase(left(i,1))) & " "
titlecaseletter = ucase(left(i,1))
xcount = len(i) - 1
titleword = right(i,xcount)
stringTextoutput = stringTextoutput & " " & titlecaseletter & titleword
Next
TCase = stringTextoutput
end function
'text output
response.write TCase(stringText)
Finding Duplicates with SQL
Here's a handy query for finding duplicates in a table. Suppose you want to find all email addresses in a table that exist more than once:
SELECT email, COUNT(email) AS NumOccurrences FROM users GROUP BY email HAVING ( COUNT(email) > 1 )
You could also use this technique to find rows that occur exactly once:
SELECT email FROM users GROUP BY email HAVING ( COUNT(email) = 1 )
Random Select Query in Database
There are lots of ways to select a random record or row from a database table. Here are some example SQL statements that don't require additional application logic, but each database server requires different SQL syntax.
Select a random row with MySQL:
SELECT column FROM table ORDER BY RAND() LIMIT 1
Select a random row with PostgreSQL:
SELECT column FROM table ORDER BY RANDOM() LIMIT 1
Select a random row with Microsoft SQL Server:
SELECT TOP 1 column FROM table ORDER BY NEWID()
Select a random row with IBM DB2
SELECT column, RAND() as IDX FROM table ORDER BY IDX FETCH FIRST 1 ROWS ONLY
Thanks Tim
Select a random record with Oracle:
SELECT column FROM ( SELECT column FROM table ORDER BY dbms_random.value ) WHERE rownum = 1
Subscribe to:
Comments
(
Atom
)
