Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


simple script question

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,53480
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> simple script question
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 simple script question - 11/13/2007 2:16:55 AM   
  90tegra

 

Posts: 8
Score: 0
Joined: 11/13/2007
Status: offline
Hey guys please help me out.I don't have a program in which i can check my script so if you can please check it for me and see if i did it according to the question? Thanks in advance

Here is the question:
A simple HTML form has been written to accept the input of a name. Write the script to retrieve the name the user input on the form remove any leading trailing blacnks from the name make the name all upper case, validate each character within the name: allowable characters are the letters from A-Z or the space character. if the name contains any other characters, put "only a-z or spaces allowed" into a variable which the user will see on the form.





<HTML><BODY>
<FORM METHOD="POST">
<PRE>
Name:
<INPUT TYPE=TEST NAME=name VALUE="<%= name %>"> <%=nameMsg %>
<INPUT TYPE=SUBMIT Name=submit VALUE="Check Name">
</PRE>
</FORM>
</BODY></HTML>
<%
Option Explicit
Dim Value
Value= A-Z
If value = A-Z
Then ucase (Value)
elseif
value <>"A-Z
Response.write "only a-z or spaces allowed"
End if
%>
 
 
Post #: 1
 
 RE: simple script question - 11/13/2007 5:19:23 AM   
  90tegra

 

Posts: 8
Score: 0
Joined: 11/13/2007
Status: offline
can anyone help me out?

(in reply to 90tegra)
 
 
Post #: 2
 
 RE: simple script question - 11/13/2007 5:43:53 AM   
  mcds99


Posts: 432
Score: 4
Joined: 2/28/2006
Status: offline
We really don't help with "home work".

Trial and error are the best teachers so keep at it.

_____________________________

Sam

Keep it Simple Make it Fun KiSMiF

(in reply to 90tegra)
 
 
Post #: 3
 
 RE: simple script question - 11/13/2007 5:51:33 AM   
  90tegra

 

Posts: 8
Score: 0
Joined: 11/13/2007
Status: offline
quote:

ORIGINAL: mcds99

We really don't help with "home work".

Trial and error are the best teachers so keep at it.


hey, i have nothing to test this program with. this is why i am asking for help. and it is not a school project it's just a tutorial i am starting on my own

thanks

(in reply to mcds99)
 
 
Post #: 4
 
 RE: simple script question - 11/13/2007 6:10:34 AM   
  ehvbs

 

Posts: 2169
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Hi 90tegra,

do you have

a computer running windows

internet explorer

the VBScript Docs (see Readme first posting)

If not, consider learning a script language that runs on your machine.

(in reply to 90tegra)
 
 
Post #: 5
 
 RE: simple script question - 11/13/2007 7:39:36 AM   
  90tegra

 

Posts: 8
Score: 0
Joined: 11/13/2007
Status: offline
thanks for the tip. but i have windows vista ultimate and none of the programs work. I just want to know if i'm on the right path with the one i created, i can't figure out why no one can give me any tips.

Thanks

(in reply to ehvbs)
 
 
Post #: 6
 
 RE: simple script question - 11/13/2007 8:07:51 AM   
  ehvbs

 

Posts: 2169
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Hi 90tegra,

there are lot's of different problems with the code you posted. If you want
to learn VBScript you should start

(a) with a simple .vbs script used from a command line to learn about the language.

(b) with a simple .hta script to come to grips with the GUI

After these steps, you can combine your knowledge/skills to wirite the .asp code.

So let's start with (a)

Save this:


      

as "checkName.vbs" and execute it from a command line (dos box) like this:

   cscript checkname.vbs

look at the output and read about all used language element (e.g. "Trim" or "If ... Then .. Else"
in the VBScript Docs. Then explain why:

Value= A-Z
If value = A-Z
Then ucase (Value)

is bad. If you post the answers here, I will show you a simple .hta.

Good luck!

ehvbs

(in reply to 90tegra)
 
 
Post #: 7
 
 RE: simple script question - 11/13/2007 8:15:55 AM   
  mcds99


Posts: 432
Score: 4
Joined: 2/28/2006
Status: offline
If vbscript is not working on the computer the DLL may not be registered.

Re-register the component using the following command, the /s makes it silent no buttons to click.

regsvr32 vbscript.dll /s

Looks like you also need the correct tags in the file like: 

VBScript only requires the file have a filename extension vbs (no HTML tags).
Example myscript.vbs

HTA  (Hyper Text Application)
HTA only requires Internet Explorer and the file name extension of hta
Example: myapp.hta


      

< Message edited by mcds99 -- 11/13/2007 8:19:20 AM >


_____________________________

Sam

Keep it Simple Make it Fun KiSMiF

(in reply to 90tegra)
 
 
Post #: 8
 
 RE: simple script question - 11/13/2007 8:45:03 AM   
  90tegra

 

Posts: 8
Score: 0
Joined: 11/13/2007
Status: offline
ok after a bit of reading i edited my script with the following but i still don't understand how to remove the leading trailing blank? (should i use MID function?):

<%
option explicit
Dim Value
Value= Request("name")

if lsNUMERIC(Value)
Response.Write "Only a-z or Spaces allowed"

Else Value="A-Z" & "a-z" Then
Ucase(name)

End if

%>


Thanks

(in reply to mcds99)
 
 
Post #: 9
 
 RE: simple script question - 11/13/2007 8:47:13 AM   
  ehvbs

 

Posts: 2169
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
This

...
</head>
<SCRIPT Language="VBScript">
this is where the VB Script goies
</SCRIPT>

<BODY>
...

should be:

...
<SCRIPT Language="VBScript">
this is where the VB Script goies
</SCRIPT>
</head>

<BODY>
...

(in reply to mcds99)
 
 
Post #: 10
 
 RE: simple script question - 11/13/2007 8:57:10 AM   
  90tegra

 

Posts: 8
Score: 0
Joined: 11/13/2007
Status: offline
quote:

ORIGINAL: ehvbs

This

...
</head>
<SCRIPT Language="VBScript">
this is where the VB Script goies
</SCRIPT>

<BODY>
...

should be:

...
<SCRIPT Language="VBScript">
this is where the VB Script goies
</SCRIPT>
</head>

<BODY>
...


sorry sir but i do not understand your reply.

thanks

(in reply to ehvbs)
 
 
Post #: 11
 
 RE: simple script question - 11/13/2007 8:58:45 AM   
  ehvbs

 

Posts: 2169
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Hi 90tegra,

did you look at the Trim() in my sample checkname.vbs?

do you really believe that

  Else Value="A-Z" & "a-z" Then
  Ucase(name)

is VBScript?

(in reply to ehvbs)
 
 
Post #: 12
 
 RE: simple script question - 11/13/2007 10:36:50 AM   
  90tegra

 

Posts: 8
Score: 0
Joined: 11/13/2007
Status: offline
ok please point me to the right direction becuase i do not understand your responses.

<%
option explicit
Dim Value
Value= Request("name")

if lsNUMERIC(Value)
Response.Write "Only a-z or Spaces allowed"

Else if Value="A-Z" & "a-z" Then
value=Ucase(name)

End if

%>

(in reply to ehvbs)
 
 
Post #: 13
 
 RE: simple script question - 11/13/2007 11:54:54 AM   
  dm_4ever


Posts: 2635
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
What you are being told is to look up the Trim function to take care of leading/trailing spaces


Else if Value="A-Z" & "a-z" Then >> this is not valid at all.  If you want to do a range or letters you will end up with a huge If...Else or Select Statement.  A regular expression would be much better suited for this, but seeing how you're having some trouble with the basics it may be a bit much at this time.

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to 90tegra)
 
 
Post #: 14
 
 RE: simple script question - 11/13/2007 2:38:32 PM   
  90tegra

 

Posts: 8
Score: 0
Joined: 11/13/2007
Status: offline
ok so looking at one of the top replies more carefully i have come up with this!! Please let me know ASAP if this looks better

<%
option explicit
Dim Value, Position, Character
Value= Request("name")
For Position = 1 to Len(Value)
Character = Mid(Value, Position, 1)
Response.Write ""& Position, "" & Character, & UCase(Character)
Character = UCase(Character)
If Value >= "A" And VAlue <= "Z" Then
Response.Write ""&Position, ""& Character
Else
Response.Write "only a-z or spaces allowed"
End if
%>


Thanks

(in reply to dm_4ever)
 
 
Post #: 15
 
 RE: simple script question - 11/13/2007 9:01:07 PM   
  ehvbs

 

Posts: 2169
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Hi 90tegra,

if you save this as checkstring.hta


      

you should be able to start it by double cklicking on the file. If it works, you can add the Trim() and
the loop code, replacing the output (.write) with suitable assignment to bOk.

Good luck!

ehvbs

(in reply to 90tegra)
 
 
Post #: 16
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> simple script question Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts