标题:ASP新手的问题关于Number and String Functions
取消只看楼主
afton
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2010-6-10
结帖率:100%
已结贴  问题点数:20 回复次数:2 
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>


搜索更多相关主题的帖子: String Number Functions ASP 
2010-06-10 08:31
afton
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2010-6-10
得分:0 
就是想我输入一个句子,统计出这个句子有多少个字(不包括空格),然后统计有多少空格,统计有几个字母A(包括大小写)。这3个功能。

现在就是有几个字母A(包括大小写)我没弄出来。
2010-06-11 06:28
afton
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2010-6-10
得分:0 
谢谢啦,我还要好好地学习一下。
2010-06-11 11:31



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-309817-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.870709 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved