Functions: Need some help getting vars to work when called

Posted on 2004-03-26
Last Modified: 2008-02-01
I have been given a function to use to generate a number. (Assume the function code is correct). When I pass my vars to it, it's not displaying the value. I believe I'm just using it wrong. Can anyone provide some assistance?  Thanks.


'Find if Consumer_ID in the database for Online Coupon routine
Dim intCID2
Dim cpnFNAME
Dim cpnLNAME
Dim strQuery2
Dim rsEmailFind2
Dim vString
Dim vKey
Dim vOffer
Dim encodeX
Dim eString

intCID2 = -1

set rsEmailFind2= Server.CreateObject("ADODB.Recordset")
strQuery2 = "SELECT Consumer.Consumer_ID, Consumer_FName, Consumer_LName FROM Consumer where Consumer.Consumer_Email = '"&Request.Form("Email")&"'"
rsEmailFind2.Open strQuery2, oConn

If Not rsEmailFind2.EOF Then
'get the consumer ID of the consumer for the Email Entered
intCID2 = rsEmailFind2("Consumer_ID")
cpnFNAME = rsEmailFind2("Consumer_FName")
cpnLNAME = rsEmailFind2("Consumer_LName")
End If
'Delete the Recordset Object
Set rsEmailFind2 = Nothing

' intCID2 now contains the PIN code for the coupons

vString = intCID2
vKey = "4gdbx8y0l6"
vOffer = "4096"
encodeX = "zkfAde37ncWxNQ8pM1VuiwG5gjvtKJSZURayFbClH6TL4IYE2OPhsqDo9rXBm"

' **********************************************************
' Coupon Function Routine (this is what I cannot get called correctly)
' **********************************************************

function EncodeCPT(vString,vKey,vOffer,encodeX)

'vString is the p code
'vKey is the Short key
'vOffer is the o code
'encodeX is the long Key

decodeX = " abcdefghijklmnopqrstuvwxyz0123456789!$%()*+,-.@;<=>?[]^_{|}~"

dim vob(2)
dim encodeModulo(256)
vob(0) = int(vOffer/100)
vob(1) = vOffer mod 100
for i = 1 to 256
encodeModulo(i) = 0

for i = 0 to 60
encodeModulo(asc(mid(decodeX,i+1,1))) = i

'append offer code to key
vString = lcase(vString) & vOffer
if len(vString) < 20 then
vString = Left(vString & " couponsincproduction",20)
end if
eString = ""
for i = 1 to j
s1 = encodeModulo(asc(mid(vString,i,1)))
s2 = 2 * encodeModulo(asc(mid(vKey,1+((i-1) mod k),1)))
s3 = vob(i mod 2)
q = (q + s1 + s2 + s3) mod 61
eString = eString & mid(encodeX,q+1,1)

EncodeCPT = eString
end function

Response.write "Fname: " &cpnFNAME & "<br>"
Response.write "Lname: " & cpnLNAME & "<br>"
Response.write "vString (ID): " & vString & "<br>"
Response.write "vOffer: " &vOffer & "<br>"
Response.write "encodeX: " & encodeX & "<br>"
Response.write "EncodeCPT: " & eString & "<br>"


The webpage displays above return:

Fname: Anthony
Lname: User
vString (ID): 1312
vOffer: 4096
encodeX: zkfAde37ncWxNQ8pM1VuiwG5gjvtKJSZURayFbClH6TL4IYE2OPhsqDo9rXBm

[Nothing for EncodeCPT]

Question by:globalwm
LVL 11

Accepted Solution

Slimshaneey earned 100 total points
ID: 10688652
Shouldnt you do it like this??
Response.write "Fname: " &cpnFNAME & "<br>"
Response.write "Lname: " & cpnLNAME & "<br>"
Response.write "vString (ID): " & vString & "<br>"
Response.write "vOffer: " &vOffer & "<br>"
Response.write "encodeX: " & encodeX & "<br>"
Response.write "EncodeCPT: " & EncodeCPT(eString) & "<br>"

Assisted Solution

sforcier earned 25 total points
ID: 10688679
You're not actually calling the function (or am I reading this wrong). Try this in your response.writes:

Response.write "EncodeCPT: " & EncodeCPT(SOMEVALUE, SOMEVALUE, SOMEVALUE, SOMEVALUE) & "<br>"

Author Comment

ID: 10688681
Yup, I got it:

Response.write "Function: " & EncodeCPT(vString,vKey,vOffer,encodeX) & "<br>"


Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now