brookd
asked on
Simple VBScript Question src=
I know my functions work. I tried to put them in a .vbs
file by themselves and then just do a
<script language="vbscript" src="encrypt.vbs">
and it will not read the functions... am I missing anything?
this is the source for the functions which works fine in the main file ..
Thank you,
- David
function Encrypt (byval str)
tempstr=""
for i=1 to len(str)
ch=mid(str,i,1)
ch=chr(asc(ch)+10)
tempstr=tempstr+ch
next
Encrypt=tempstr
end function
function Decrypt (byval str)
tempstr=""
for i=1 to len(str)
ch=mid(str,i,1)
ch=chr(asc(ch)-10)
tempstr=tempstr+ch
next
Decrypt=tempstr
end function
file by themselves and then just do a
<script language="vbscript" src="encrypt.vbs">
and it will not read the functions... am I missing anything?
this is the source for the functions which works fine in the main file ..
Thank you,
- David
function Encrypt (byval str)
tempstr=""
for i=1 to len(str)
ch=mid(str,i,1)
ch=chr(asc(ch)+10)
tempstr=tempstr+ch
next
Encrypt=tempstr
end function
function Decrypt (byval str)
tempstr=""
for i=1 to len(str)
ch=mid(str,i,1)
ch=chr(asc(ch)-10)
tempstr=tempstr+ch
next
Decrypt=tempstr
end function
Perhaps you're confusing local vbscript files on a windows system with using them server-side on an ASP platform?
Perhaps this helps?:
function Encrypt (byval str)
tempstr=""
for i=1 to len(str)
ch=mid(str,i,1)
ch=chr(asc(ch)+10)
tempstr=tempstr+ch
next
Encrypt=tempstr
end function
function Decrypt (byval str)
tempstr=""
for i=1 to len(str)
ch=mid(str,i,1)
ch=chr(asc(ch)-10)
tempstr=tempstr+ch
next
Decrypt=tempstr
end function
MsgBox Encrypt("ABCDE")
MsgBox Decrypt("PQRST")
Perhaps this helps?:
function Encrypt (byval str)
tempstr=""
for i=1 to len(str)
ch=mid(str,i,1)
ch=chr(asc(ch)+10)
tempstr=tempstr+ch
next
Encrypt=tempstr
end function
function Decrypt (byval str)
tempstr=""
for i=1 to len(str)
ch=mid(str,i,1)
ch=chr(asc(ch)-10)
tempstr=tempstr+ch
next
Decrypt=tempstr
end function
MsgBox Encrypt("ABCDE")
MsgBox Decrypt("PQRST")
Oops, I meant this:
whatever.vbs:
=============
function Encrypt (byval str)
tempstr=""
for i=1 to len(str)
ch=mid(str,i,1)
ch=chr(asc(ch)+10)
tempstr=tempstr+ch
next
Encrypt=tempstr
end function
function Decrypt (byval str)
tempstr=""
for i=1 to len(str)
ch=mid(str,i,1)
ch=chr(asc(ch)-10)
tempstr=tempstr+ch
next
Decrypt=tempstr
end function
MsgBox Encrypt("ABCDE")
MsgBox Decrypt("KLMNO")
whatever.vbs:
=============
function Encrypt (byval str)
tempstr=""
for i=1 to len(str)
ch=mid(str,i,1)
ch=chr(asc(ch)+10)
tempstr=tempstr+ch
next
Encrypt=tempstr
end function
function Decrypt (byval str)
tempstr=""
for i=1 to len(str)
ch=mid(str,i,1)
ch=chr(asc(ch)-10)
tempstr=tempstr+ch
next
Decrypt=tempstr
end function
MsgBox Encrypt("ABCDE")
MsgBox Decrypt("KLMNO")
Hi
If u are trying for Server side ASP scripting, These guidelines may help u,
What ever be the vbs file, keep in a directory in the server.
In the ASP file where u want to access these functions, include the .vbs file as follows
<!--#include /dir/filename.vbs-->
then u can access these functions as if it is coded in the same asp page as u are witing now
If u are trying for Server side ASP scripting, These guidelines may help u,
What ever be the vbs file, keep in a directory in the server.
In the ASP file where u want to access these functions, include the .vbs file as follows
<!--#include /dir/filename.vbs-->
then u can access these functions as if it is coded in the same asp page as u are witing now
ASKER
Hi,
I forgot to mention that I was not using asp ..
I thought that I could create a vbs file just the same
as creating a jscript file .js and that I could
include my functions with no problem , but maybe
plain Vbscript doesn't allow a src include like Jscript.
/? ? ? Thank you for all of your responses.
-- David
(I would have the point value increased but I only had
< 50 points and the system wouldn't let me. .. ) :)
I forgot to mention that I was not using asp ..
I thought that I could create a vbs file just the same
as creating a jscript file .js and that I could
include my functions with no problem , but maybe
plain Vbscript doesn't allow a src include like Jscript.
/? ? ? Thank you for all of your responses.
-- David
(I would have the point value increased but I only had
< 50 points and the system wouldn't let me. .. ) :)
Maybe your missing the type attribute:
<script language="vbscript" type="text/vbscript" src="encrypt.vbs"></script >
?
<script language="vbscript" type="text/vbscript" src="encrypt.vbs"></script
?
(I did not try it, so no wonder please, if it does not work.)
Are you trying to use VBScript client-side?
If so I'm not sure about how to include them, but I would advise against doing so anyway if this is the case (unless this is for an intranet application where you KNOW everyone ABSOLUTELY uses Internet Explorer), since VBScript is only supported by Internet Explorer client-side.
Just a thought...
If so I'm not sure about how to include them, but I would advise against doing so anyway if this is the case (unless this is for an intranet application where you KNOW everyone ABSOLUTELY uses Internet Explorer), since VBScript is only supported by Internet Explorer client-side.
Just a thought...
If you are using VBScript for client side coding, use the following code to include the vbs file.
<script language="vbscript" src="encrypt.vbs">
</script>
And then call the VB function using the following
<script>
strEnc=Encrypt(somestring)
</script>
(provided you have declared strEnc and somestring)
Pls note that this works only in I.E.
HTH,
craZcoder.
<script language="vbscript" src="encrypt.vbs">
</script>
And then call the VB function using the following
<script>
strEnc=Encrypt(somestring)
</script>
(provided you have declared strEnc and somestring)
Pls note that this works only in I.E.
HTH,
craZcoder.
ASKER
craZcode ,
You would think this would work.
<script language="vbscript" src="c:\encrypt.vbs"><scri pt>
<script language="vbscript">
dim s,t
s="Hello World"
msgbox (s)
' document.write (s)
t=encrypt(s)
document.write (t)
</script>
But for some reason it doesn't..
Out of desparation, here is the whole program.. Can you
convert it into two files... and test it with IE ?
<script language="vbscript">
s="Hello World"
msgbox (s)
' document.write (s)
t=encrypt(s)
document.write (t)
function Encrypt (byval str)
tempstr=""
for i=1 to len(str)
ch=mid(str,i,1)
ch=chr(asc(ch)+10)
tempstr=tempstr+ch
next
Encrypt=tempstr
end function
function Decrypt (byval str)
tempstr=""
for i=1 to len(str)
ch=mid(str,i,1)
ch=chr(asc(ch)-10)
tempstr=tempstr+ch
next
Decrypt=tempstr
end function
</script>
You would think this would work.
<script language="vbscript" src="c:\encrypt.vbs"><scri
<script language="vbscript">
dim s,t
s="Hello World"
msgbox (s)
' document.write (s)
t=encrypt(s)
document.write (t)
</script>
But for some reason it doesn't..
Out of desparation, here is the whole program.. Can you
convert it into two files... and test it with IE ?
<script language="vbscript">
s="Hello World"
msgbox (s)
' document.write (s)
t=encrypt(s)
document.write (t)
function Encrypt (byval str)
tempstr=""
for i=1 to len(str)
ch=mid(str,i,1)
ch=chr(asc(ch)+10)
tempstr=tempstr+ch
next
Encrypt=tempstr
end function
function Decrypt (byval str)
tempstr=""
for i=1 to len(str)
ch=mid(str,i,1)
ch=chr(asc(ch)-10)
tempstr=tempstr+ch
next
Decrypt=tempstr
end function
</script>
Hmm, have you verified that the path c:\encrypt.vbs is correct? That definitely would not work on a webpage, I have never included a .vbs file like that either... so I am not sure if that works!
Should'nt files of such locations be defined with something like file:///C:/encrypt.vbs ?
However, put the file in the same folder as the html file is and just set the src to "encrypt.vbs" only.
However, put the file in the same folder as the html file is and just set the src to "encrypt.vbs" only.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Both CraZCoder and spiritwithin are correct , strange I thought I tried that,.. but I probably made a typo.. I increased the point value,, and I'm going to award to CraZCoder ... Thank you all !
Here's what I ended up with:
<script language="vbscript" src="file:///c:\encrypt.vb s"></scrip t>
<script language="vbscript">
s="Hello World"
msgbox (s)
' document.write (s)
t=encrypt(s)
document.write (t)
</script>
-- David
Here's what I ended up with:
<script language="vbscript" src="file:///c:\encrypt.vb
<script language="vbscript">
s="Hello World"
msgbox (s)
' document.write (s)
t=encrypt(s)
document.write (t)
</script>
-- David
ASKER
It wouldn't let me increase the point value, sorry..
Keep in mind that the .vbs file can be downloaded, so this isn't secure at all. :=|
ASKER
yes, this was just for fun,.. if I had access to asp , I would have written it there,.. it seemed easiest to write with vb string functions . . .
Thank you all ...
Thank you all ...
Example:
time.vbs:
MsgBox Now()
MsgBox FormatDateTime(Now(), 0)
MsgBox FormatDateTime(Now(), 1)
MsgBox FormatDateTime(Now(), 2)
MsgBox FormatDateTime(Now(), 3)
MsgBox FormatDateTime(Now(), 4)