Jump to content


Asp & Vb....


  • Please log in to reply
5 replies to this topic

#1 NickyEng

NickyEng

    Member

  • Members
  • PipPip
  • 81 posts
  • Location:Petaling Jaya, Malaysia
  • Interests:Simple Me

Posted 16 March 2005 - 10:03 PM

i'm writing an simple asp application code that creates and calles the VBscript function called max that gets an array as input,and return the highest value in an array of numbers or return null, if no numeric items are foun in the array.


Im still new to ASP...so SENIORS pls correct me if my following code has something wrong...thank you guys.....:

filename : ASP_VB.asp
--------------------------------------------------------------------------
<html>
<head>
<title>ASP_VB </title>
</head>
<body>
<form action="ASP_VB.asp" method="post">
<br>
<input type="text" name="mytext">
<input type="submit" value="display">
</form>
<br>
<br>

<%

Dim keep_track()
Dim i
Dim value_get

For i = 1 to 3
keep_track(i) = Request.Form("mytext")
Next
%>
<%
<script>
Function max(keep_track(i))
If keep_track(i) > (keep_track(i+1)&keep_track(i+2))then
Response.write(keep_track(i))
elseif keep_track(i+1) > (keep_track(i)&keep_track(i+2))then
Response.write(keep_track(i+1))
else
Response.write(keep_track(i+2))
End if
End Function
</script>

%>

</body>
</html>

-------------------------------------------------------------------------

#2 guanerrr

guanerrr

    Super Member

  • Members
  • PipPipPipPip
  • 680 posts
  • Location:Somewhere in 8th Layer
  • Interests:whay

Posted 17 March 2005 - 04:19 PM

can U tell me what's the error message? It can help me to fix the bug. I don't have time to run the script. Sorry..

#3 madgino

madgino

    Newbie

  • Members
  • Pip
  • 1 posts

Posted 18 March 2005 - 01:59 AM

There are a lot of mistakes in there (almoust everything), you better tell us what you want this script to do so we can better help you

#4 NickyEng

NickyEng

    Member

  • Members
  • PipPip
  • 81 posts
  • Location:Petaling Jaya, Malaysia
  • Interests:Simple Me

Posted 18 March 2005 - 11:54 AM

halo guys, thanks for getting your response.

i know the error already....dont need to reply me anymore...

i need more html input text box to enter more value, such as 4 text box to enter 4 value.....and then click "Compare" button...after that, it will show the highest value in output in the same page......

thanks again....i solved my problem already... :D

here is my coding:
--------------------------------------------------------------------

<html>
<head>
<title>Comparing Arrays</title>
</head>
<body>
<form name="input" method="post" action="array.asp">
Enter input 1<input type="textbox" name="input1">
<br>
Enter input 2<input type="textbox" name="input2">
<br>
Enter input 3<input type="textbox" name="input3">
<br>
Enter input 4<input type="textbox" name="input4">
<br>
<input type="submit" value="Find Max Number">
</form>

<%
Dim myArray(3)

myArray(0) = Request.Form("input1")
myArray(1) = Request.Form("input2")
myArray(2) = Request.Form("input3")
myArray(3) = Request.Form("input4")

Call max(myArray(0), myArray(1), myArray(2), myArray(3))
%>
<br><br>
<%
Public Function max(ByVal a, ByVal b, ByVal c, ByVal d)
If a > b Then
If a > c Then
If a > d Then
Response.write(a)
Else
Response.write(d)
End If
Else
If c > d Then
Response.write©
Else
Response.write(d)
End If
End If
Else
If b > c Then
If b > d Then
Response.write( B)
Else
Response.write(d)
End If
Else
If c > d Then
Response.write©
Else
Response.write(d)
End If
End If
End If

End Function
%>
</body>
</html>
------------------------------------------------------------------------------------
thanks again :)

do you guys have anything add into the coding above?

like...how to prevent String input if we key in characters or string value, etc....

#5 mnewman943

mnewman943

    Newbie

  • Members
  • Pip
  • 5 posts

Posted 19 March 2005 - 01:15 AM

halo guys, thanks for getting your response.

i know the error already....dont need to reply me anymore...

i need more html input text box to enter more value, such as 4 text box to enter 4 value.....and then click "Compare" button...after that, it will show the highest value in output in the same page......

thanks again....i solved my problem already... :D

here is my coding:
--------------------------------------------------------------------

<html>
<head>
<title>Comparing Arrays</title>
</head>
<body>
<form name="input" method="post" action="array.asp">
Enter input 1<input type="textbox" name="input1">
<br>
Enter input 2<input type="textbox" name="input2">
<br>
Enter input 3<input type="textbox" name="input3">
<br>
Enter input 4<input type="textbox" name="input4">
<br>
<input type="submit" value="Find Max Number">
</form>

<%
Dim myArray(3)

myArray(0) = Request.Form("input1")
myArray(1) = Request.Form("input2")
myArray(2) = Request.Form("input3")
myArray(3) = Request.Form("input4")

Call max(myArray(0), myArray(1), myArray(2), myArray(3))
%>
<br><br>
<%
Public Function max(ByVal a, ByVal b, ByVal c, ByVal d)
If a > b Then
If a > c Then
If a > d Then
Response.write(a)
Else
Response.write(d)
End If
Else
If c > d Then
Response.write©
Else
Response.write(d)
End If
End If
Else
If b > c Then
If b > d Then
Response.write( B)
Else
Response.write(d)
End If
Else
If c > d Then
Response.write©
Else
Response.write(d)
End If
End If
End If

End Function
%>
</body>
</html>
------------------------------------------------------------------------------------
thanks again :)

do you guys have anything add into the coding above?

like...how to prevent String input if we key in characters or string value, etc....

String builder has a LOT of really nice features, and you might want to take a look at some examples or I could paste some for your situation if need be.

Another item you might want to consider are validation or custom validation controls. Depending on the user environment you can use regular expressions to clean up textbox info based upon business rules, etc., or you may consider using various events etc to not allow certain key input...

Those are just a couple of ideas, the smaller you make the code the easier it is to trace and debug. If possible I would go right to string builder and get away from the arrays you are using, I am not slamming anyone because I don't know the situation for it but, readability, flow, and performance can be resolved by using string builder and regular expressions.

#6 NickyEng

NickyEng

    Member

  • Members
  • PipPip
  • 81 posts
  • Location:Petaling Jaya, Malaysia
  • Interests:Simple Me

Posted 20 March 2005 - 06:00 AM

thanks for your reply...

really appreciated your comment....
:)

the coding is required by my assignment questions, the question need me to use array, so i just follow the instruction to get my marks.....

i'm very new to VB and ASP....still learning and is going to have test.....now i'm doing the JAVA assignments... need to create a MyPet program....

Thanks for your reply... :)





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users