We know that vbs has a trim function, which is used to remove spaces at both ends of a string. As is not available, we can customize:
// Removes leading and trailing spaces of a string.
Function Trim (returnstring) {
For (; Returnstring. charcodeat ( 0 ) = 0x20 ; Returnstring = Returnstring. substr ( 1 )) {
}
For (; Returnstring. charcodeat (returnstring. Length - 1 ) = 0x20 ; Returnstring = Returnstring. substr ( 0 , Returnstring. Length - 1 )) {
}
Return Returnstring;
}
// Return the front and back of the string
Public static Function Trimenter (returnstring) {
For (; Returnstring. substr ( 0 , 1 ) = String. fromcharcode ( 13 ); Returnstring = Returnstring. substr ( 1 )) {
}
For (; Returnstring. substr (returnstring. Length - 1 , 1 ) = String. fromcharcode ( 13 ); Returnstring = Returnstring. substr ( 0 , Returnstring. Length - 1 )) {
}
Return Returnstring;
}
This is also commonly used: // Byte conversion kb, MB
Function Getsizetype (size: Number) {
If (Size < 1024 ) {
Return Int(Size*100)/100+"Bytes";
}
If (Size < 1048576 ) {
Return Int(Size/1024)*100)/100+"KB";
}
If (Size < 1073741824 ) {
Return Int(Size/1048576)*100)/100+"MB";
}
Return Int (Size / 1073741824 ) * 100 ) / 100 + " GB " ;
}
Verify that the entered content is a number:If(Isnan("Content to be verified")= True){
Trace("A non-number is entered");
}Else{
Trace("Number entered");
}