2012-07-14

VBScript函數--字元字串處理--Space傳回指定長度空白字元所組成的空白字串

Space → 傳回指定長度空白字元所組成的空白字串
語法:Space(length)


函數長度執行函數寫法結果訊息
Space
(如無法正常測試,建議使用IE瀏覽器)
<script language="vbscript">
  <!--
    sub run_Space()
        document.all("lblSpace").innerHTML = ""
        document.all("Space3").innerHTML = ""
        if not isNumeric(document.all("Space1").value)  then
            document.all("lblSpace").innerHTML = "請輸入正整數"
            document.all("Space3").innerHTML = ""
            document.all("Space2").innerHTML = ""
            document.all("Space1").value = ""
            document.all("Space1").focus
            exit sub
        end if
            document.all("Space2").innerHTML = "Space(" & chr(34) & document.all("Space1").value & chr(34) & ")"
            document.all("Space3").innerHTML = Replace(Space(document.all("Space1").value)," ",".")
            document.all("lblSpace").innerHTML = "用1點代表1空白字元!"
    end sub
  -->
</script>
<br />
<table>
<tbody>
<tr>
    <td>函數</td><td>長度</td><td>執行</td><td>函數寫法</td><td>結果</td><td>訊息</td>
</tr>
<tr>
    <td>Space</td>
    <td><input id="Space1" name="Space1" type="text" maxlength=2 style="width:20px"/></td>
    <td><input id="btnSpace" name="btnSpace" onclick="run_Space()" type="button" value="Run" /></td>
    <td><label id="Space2" name="Space2"></label></td>
    <td><span id="Space3" name="Space3" style="background-color:#FF0000;"></span></td>
    <td><label id="lblSpace" name="lblSpace"></label></td>
</tr>
</tbody> 
</table>

沒有留言:

張貼留言