In this article the author will share a bit of knowledge about the ASP programming ranging from functions, constants, and other variables, as well as will be given an example of a simple example, in this case the author deliberately does not display all the results of execution in the hope readers can try it for yourself.
logic Programming
Data types can be used to store data and generally we data store data as a variable, the variable has a name and a value. Variable variable name determines how it will be called and the value is the data that is stored in the variable. Like other conventional programming languages, we declare variables first so that will be executed and will also speed up the execution time of the program.
variables
To declare a variable in ASP programming, we
using the DIM statement like the following:
Dim variable_name
for example:
Dim value
After doing the above declaration as an example then we fill a value to the variable. To fill it we use the operator assignment (assignment operator) such as:
value = 15
Variable value over the numeric value 15. There are some hints variable naming them, must begin with a character alpabet, can not contain a point or character to type declarations, must same unique range (see the below for notes on range, should be 255 characters or less. Examples in the Declarations a variable in a short looping program, here is an example.
<% Dim HP HP = "LG" If HP = "Nokia" Then%>
HP we
<% Else%> HP us another yes <% End If%>
Results: HP us another yes
string
Used to store data in the form of text, characters, or a collection of character, writing enclosed in quotes ("), the following is an example:
<html>
<head>
<title>Fungsi STRING </title>
</head>
<body>
<script language="vbscript">
document.write "<br>"
document.write "menampilkan currency = "
document.write formatcurrency(10000,2)
document.write "<br>"
document.write "menampilkan tanggal longdate = "
document.write formatdatetime("27/07/2004", vblongdate)
document.write "<br>"
document.write formatpercent(30/100,2)
</script>
</body>
</html>
function
In the VBScript script there are some standard functions that already exist, we can Such function call by declaring in advance, for example:
<html>
<head>
<title>contoh function</title>
</head>
<body>
<%
function Hari_Esok()
Hari_ini = Date()
Hari_Esok = Hari_ini + 1
end Function
response.write ("<H1> Panggil Fungsi </H1>")
response.write ("Besok Tanggal : "& Hari_Esok ())
%>
</body> </html>
constants
Some variable values can not be changed during program execution and we can make as a constant. Value remains constant until the program ends, defining constants is done along with the declaration, for example:
for example:
Const pi = 3.14 The
Constants are very useful in mathematical calculations in and physics. Constants also have boundary definition, so a constant can also be has a definition that limits local and global, way of doing this restriction
the same as the variable, namely;
Public Const pi = 3.14 The
Private Const name = "Ari Fadli"
<html>
<head>
<title>konstanta</title>
</head>
<body>
<%
Const pi = 3.14
Const kata = "Nilai pi adalah = "
Response.write("<h1>" & kata & pi & "</h1>")
%>
</body>
</html>