No announcement yet.

Learn ASP with Bupbeyeu!

  • Filter
  • Time
  • Show
Clear All
new posts

  • Learn ASP with Bupbeyeu!

    Hi all,ASP can used to insert in more site on Net.
    Now i tell u how to learn ASP....
    What's ASP?
    ASP is Microsoft's OLE / ActiveX scripting environment. It allows programs or scripts to be ran from within HTML documents on the server, and the program code is replaced with the resulting HTML code. ASP is not an actual scripting language, just an environment that allows you to choose and use a scripting language. At the moment, only two languages can be used: VBScript, a toned down version of Visual Basic; and JScript, a Microsoft version of JavaScript (which, I add, is not compatible with JavaScript used by other browsers).

    When you put scripts inside HTML documents you must enclose them with a <% to start and a %> to end the scripted part of the document. All text outside of these delimiters (a symbol used to mark a starting and stopping point) is just like a regular HTML document, just plain text with funny looking names in <>s.

    Commands and statements in the script are usually ran in the order they appear in the file, but there are commands that can change this.

    Here is a sample of an HTML document with ASP script in it.

    BODYbgcolor=White text
    P>Here is my script:</P
    <%Response.Write(Server.HTMLEncode("Script this boy..."))
    For i = 0 To 10
    Current Number is <%=Server.HTMLEncode(i)%>


  • #2
    Printing Into a Page

    Printing text to the HTML part of the document is the easiest part of all in my opinion.

    All you have to do is call the Response.Write method with the text to be printed in "", for example:

    Response.Write("Something boring to say.")

    Another way to do this is to put an = right after a <% and a %> at the end of the line, for example:

    <%="Something boring to say."%>

    or to print a variable, for example:

    Response.Write(i) or <%=i%>


    • #3

      A variable is nothing more than a friendly name (programmer/human friendly) for a value. A value can be a number, an object, or a string of text(writing). To create a variable, all you have to do it to use the name anywhere in the script. You can use the name in an equation or just assign it a value, right off the bat, for example:

      Name = "Steven Vo"
      Address = "DLX Ave."
      Ducks = 5
      Geese = 6
      Moose = Ducks * Geese


      • #4

        A function is a command that returns a value that you can store in a variable. Function, just like commands, may require some extra information that is placed in ( ) and separated by commas. In other words, you can say this:

        MoFo = sqr(4)

        Which means MoFo is equal to sqr(4), the square root of 4.

        But you can't do this, or at least not have a reason to:

        MoFo = Response.End

        This is because Response.End is not a function, it is a command, it does not return a value that MoFo can equal to.


        • #5
          Simple Math

          Math and logic are both a part of computer science; but, right now, let's talk about math. A computer can only do simple math, but people can write functions to make it do hard math. First we will talk about the simple math and a few simple functions that VBScript offers:

          As you can see, the symbols used to do the math are easy to understand.
          • + for add
          • - for subtract
          • * for multiply
          • / for divide
          • \ for whole number divide
          • ^ for "to the power of"
          • ( ) for "do this first"
          • = for "is equal to"

          MoFo = 5 + 6 ^ (2 * 4) * 4

          When a variable refers to itself in a statement, it is referring to its current value, the value it had before this statement came up. Example:

          MoFo = 5 'Of course MoFo is 5
          MoFo = MoFo + 1 'Now MoFo is it's current value, 5, plus one, now MoFo will = 6
          MoFo = MoFo - 2 'MoFo is it's old value, 6, minus 2, now it will = 4

          There are also some simple math functions that you can use:
          • sqr (number) for the square root of number
          • int (number) for the whole number part of number
          • fix (number) to round off number to a whole number

          MoFo = sqr(MoFo) + 5 * 6


          • #6

            string is an array, a series of letters and numbers between two "s. Strings are used to hold text and numbers in a human-readable form. An example of a string is:

            JJsString = "I am a BIG string of useless text."
            AlfsString = "I am a small string."

            There is only one kind of math you can perform on strings because strings are not numbers that the computer understands but letters and numbers. The +, add, will combine two strings into one string like so:

            HHE = "May I see that." + " It looks cool".

            HEE would be "May I see that. It looks cool."

            You can also use the & sign which will combine any variable with a string (converting non-string variables to strings just for that moment)

            i = 5
            HHE = "My number is " & i

            HHE would be "My number is 5"

            There are a number of functions you can use on strings. Some of the more common are:
            • val(string) to convert a string or the number part of it to a number variable.
            • instr(start, string, string2) to give the number position of a place in string where string2 might be seen starting at the number variable start.
            • mid(string, start, length) to return the string of text length characters in size starting at start in string.
            • cstr(number) to convert a number variable into a string.


            • #7

              Arrays are variables with multiple values. They can be used for many purposes. Each value is referred to by a number in ()s after the variable name for the array and set based on that number. An array's elements can contain any type of data.

              Creating an Array

              Creating an array is simple and there are many different ways to do it. The following ways can be used, but should not be combined:
              • Dim ArrayName (Elements) Use this to setup an array with Element number of values.
              • Dim ArrayName () Use this to set up an array with no given number of values, you can add as many values as you want, but this is used in the case where you set up may setup an array that will change size. To change its size, just call:
                ReDim [Preserve] ArrayName (Elements), use preserve only when you want to keep the last array's values.
              • Dim ArrayName
                Set ArrayName = Array("ElementValue1", "ElementValue2")
                Use this to define the values for the array's elements when it is created.
              Using an Array

              To set and retrieve the values in an array, all you need to do is give the array's name with a number in ()s. This number is the value or element you want. Examples:

              'To set arrays
              ArrayName(4) = "Nobody home"
              ArrayName2(4) = 24
              'To use their values
              Name = "Homer " & ArrayName(2)
              A = 33 * ArrayName2(3)

              'Using arrays in functions
              'Passing an element as a variable
              B = SQR(NumArray(1))
              'Passing an entire array to a function expecting an array.
              UserID = 5
              UserName = FindUser (UserNameArray, UnserIDArray, UserID)

              When using an array as the parameter in a function, you must know how the array is being used for that function. If you just need one of its elements as a parameter, then you must include the element identifier, the number in ()s. This is when you are using the element in place of a normal variable. When, you need an array as the parameter and not a single element; then use its name without the number in the ()s.


              widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.