Skill
1. Several common functions
Round (pi, 2) rounded
FormatNumber (k,4) ' formats K as a number with four-bit decimal points.
eg. If K =20000 is shown as 20,000.00 if FormatNumber (k,0) is 20,000
Replace (Expression,find,replacewith) ' returns a string in which the specified substring has been replaced by another substring
Left (string,length) ' Returns a specified number of strings from the left-hand side of the string.
Split (expression[, delimiter[, count[, start]]] ' Returns a one-dimensional array based on 0 that contains the specified number of substrings.
eg. This split (String,[delimiter]) is used to divide strings using delimiter (characters used to identify substring bounds)
Instr (string1,string2) ' Returns the position of the first occurrence of a string in another string
Eg1. If InStr (addation, "Password Configuration table") <>0 Then ' description exists
EG2. If InStr (str, "AP") >0 a bad distinction between str = (AP,AP&AC), just change (' ap ', ' Ap&ac '), and then use InStr (STR, ' AP ')
2. pop-up window pick value
function PICKUPSP (Spdisid,pjnum,pdcode)
{
Window.opener.<%=theform%>. refnum<%=spid%>.value=spdisid;
Window.opener.<%=theform%>. lines<%=spid%>.value=pjnum;
window.opener.<%=theform%>.kokey<%=spid%>.value=pdcode;
Window.close ();
}
3. asp control picture display size (equal scaling)
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<script language= "JavaScript" >
<!--
var flag=false;
Function DrawImage (IMGD) {
var image=new image ();
Image.src=imgd.src;
if (image.width>0 && image.height>0) {
Flag=true;
if (image.width/image.height>= 164/112) {
if (image.width>164) {
imgd.width=164;
imgd.height= (image.height*164)/image.width;
}else{
Imgd.width=image.width;
Imgd.height=image.height;
}
imgd.alt=image.width+ "x" +image.height;
}
else{
if (image.height>112) {
imgd.height=112;
Imgd.width= (image.width*112)/image.height;
}else{
Imgd.width=image.width;
Imgd.height=image.height;
}
imgd.alt=image.width+ "x" +image.height;
}
{
}
//-->
</script>
</HEAD>
<BODY>
<a href= "http:// Www.webjx.com/htmldata/2006-01-29/img.jpg "target=" _blank "></a>
</BODY>
</HTML>
4. Operations on database tables (insert/update/delete) in ASP, using transaction processing and support for multiple transaction processing.
In the ASP's database object linked object, the properties are provided:
BeginTrans Transaction Start
CommitTrans Transaction Submission
RollbackTrans transaction Rollback
<%
On Error Resume Next ' error occurs after processing
' Using Transactions in ASP '
Set conn=server.createobject ("ADODB. Connection ")
Conn. Open "Course_dsn", "Course_user", "Course_password"
Conn.begintrans ' Start a transaction
Sql= "Delete from User_info"
Set Rs=server.createobject ("Adodb.recordset")
Rs.Open sql,conn,3,3
If Conn.errors.count>0 then ' has an error occurred
Conn.rollbacktrans ' Roll back
Set rs=nothing
Conn.close
Set conn=nothing
Response.Write "Transaction failure, roll back to the state before the change!" "
Response.End
Else
Conn.committrans ' commits the transaction
Set rs=nothing
Conn.close
Set conn=nothing
Response.Write "Trading Success! "
Response.End
End If
%>
In the ASP, do not provide the end of the transaction, BeginTrans only for their own domain, similar to the variable declaration, if in the function body BeginTrans, then the object is used only for this function body, if BeginTrans in the function body, in the page level, The scope of the transaction begins at BeginTrans, and the end of the page is in the managed state of the transaction.
5. Easysales Database Operations
Dim objcon,objrst,objsql
Dim CompanyID
Set Objcon = Server.CreateObject ("ADODB. Connection ")
Objcon.open Sysdns,sysname,syspassword
Set Objrst = Server.CreateObject ("ADODB. RecordSet ")
Objsql= "SELECT * from Passwordconfig where companyid= '" &session ("CompanyID") & ""
Objrst.open objsql,objcon,1,3
6. html format mail sent
HTML = "html = html & "html = html & "<title>sending cdonts Email Using html</title>"
html = html & "<link href=". /cn/new.css "rel=" stylesheet "type=" Text/css ">"
html = html & "html = html & "<body bgcolor=" "FFFFFF" ">"
html = html & "<p><font size=7>"
html = HTML & "This are a test mail in html<br>"
html = html & "Mail content here ...</font></p>"
html = html & "</body>"
html = html & "Dim strrecemail,strposemail,strsubject,strbody
Strrecemail=request ("email")
Strposemail= "yufh@alleasy.com.cn"
strsubject= "Information Download notification letter"
Strbody=html
7. Input is underlined
Style= "Border-right: #f7f7f7 0px solid; Border-top: #f7f7f7 0px solid; font-size:9pt; Border-left: #f7f7f7 0px solid; width:110px; Border-bottom: #c0c0c0 1px solid; height:16px; Background-color: #f7f7f7 "
8. Session & Cookies
Write a session:
session["username"] = "AA";
Session ("username") = "AA"
Read a Sessinn:
String username= session["username"];
Dim username=session ("username")
Cookies are roughly the same as this usage
9. The constant in several VB
The following constants are defined by the type library in Visual Basic for applications, and can be used to replace the actual value anywhere in the code:
Constant equals description
VbCrLf Chr + Chr (10) carriage return and newline character combination
vbcr CHR (13) return character
VBLF CHR (10) line feed
vbNewLine Chr + Chr (10) platform-specified new line character; for the current platform
vbNullChar Chr (0) a character with a value of 0
A string with a vbNullString value of 0 is used to invoke an external procedure, unlike a zero-length string ("")
vbObjectError-2147221504 the user-defined error number should be greater than this value, for example:
Err.Raise Number = vbObjectError + 1000
VbTab Chr (9) Tab.
Vbback CHR (8) BACKSPACE character
10. Button is not available
<%if rsview.eof and Rsview.bof then%> ' There's a big problem here.
<input name= "Submit" type= ' Submit ' value= ' to the selected user to unlock ' disabled>
<%else%>
<input name= "Submit" type= ' Submit ' value= ' to the selected user unlock ' >
</td>
<%end if%>