ASP新手的问题关于Number and String Functions
问题是这样的,编一个 script counts the number of letters (do not count spaces), the number of spaces and the number of “A”s (capital or small)我现在就是the number of “A”s (capital or small)这一部分弄不出来,大家教教我呀!!
<%
Option Explicit
Dim intspaces, txtwholething, counter
'grab the string from the textbox
txtwholething = Request("thestuff")
'output the length of the string
if txtwholething <>"" then
Response.write "You entered a string of " & Len(txtwholething) & " characters long<br>"
'find out how many spaces are in the string
'since we know how long the string is, use a For Next loop
For counter = 1 to Len(txtwholething)
'start going through the string one letter at a time
'the counter value tells the MID( ) function which letter to get next
If MID(txtwholething, counter, 1) = " " Then
'keep track of the number of spaces found
intspaces = intspaces + 1
End If
'if we are not at the end of the string, go back and get another character
Next
'When we are done output the number of spaces
Response.write "There are " & intspaces & " space(s) in the string"
end if
%>
<HTML><HEAD><TITLE>Student Login Form</TITLE></HEAD>
<BODY BGCOLOR = "#CCFFCC">
<FORM METHOD=POST>
Enter a word or sentence:
<INPUT TYPE=TEXT NAME="thestuff"><BR><BR>
<INPUT TYPE=SUBMIT VALUE="Click to Enter">
</FORM>
</BODY>
</HTML>