| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 545 人关注过本帖
标题:ASP新手的问题关于Number and String Functions
只看楼主 加入收藏
afton
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2010-6-10
结帖率:100%
收藏
已结贴  问题点数:20 回复次数:4 
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
gupiao175
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:40
帖 子:1787
专家分:7527
注 册:2007-6-27
收藏
得分:0 
你想实现一个把一个字母或一个句子转化为大写或小写的,并统计其字符个数的函数??是这样吗?

Q:1428196631,百度:开发地 即可找到我,有事请留言!
2010-06-10 14:44
afton
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2010-6-10
收藏
得分:0 
就是想我输入一个句子,统计出这个句子有多少个字(不包括空格),然后统计有多少空格,统计有几个字母A(包括大小写)。这3个功能。

现在就是有几个字母A(包括大小写)我没弄出来。
2010-06-11 06:28
hams
Rank: 12Rank: 12Rank: 12
等 级:贵宾
威 望:18
帖 子:912
专家分:3670
注 册:2008-7-30
收藏
得分:20 
<%
Option Explicit
Dim intspaces, intspacesa, txtwholething, counter, sstring
'grab the string from the textbox
txtwholething = Request("thestuff")
'output the length of the string
if txtwholething <>"" then
    intspaces =0
    intspacesa =0
    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)
        sstring=MID(txtwholething, counter, 1)
        If ASC(sstring)=32 Then intspaces = intspaces + 1
        If ASC(sstring)=65 or ASC(sstring)=97 Then intspacesa = intspacesa + 1
    Next

    'When we are done output the number of spaces
    Response.write "There are " & intspaces & " space(s) in the string"
    Response.write "There are " & intspacesa & " A 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>

俺不高手,俺也是来学习的。
俺的意见不一定就对,当你不认同时请点忽视按钮。
当走到十字路口不知该如何走时,可在论坛问下路,但你若希望别人能一路把你送到目的地,显然是不现实的,因为别人也有自己要走的路。
2010-06-11 08:45
afton
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2010-6-10
收藏
得分:0 
谢谢啦,我还要好好地学习一下。
2010-06-11 11:31
快速回复:ASP新手的问题关于Number and String Functions
数据加载中...
 
   



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

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