2010年8月6日金曜日

htaでtextarea

Check

せっかくなのでtextareaに表示しましょう。

MsgBoxを「document.form1.result.value = 」に変えて。

document.form1.result.value = strTemp

実行するとこんな感じに。

screen_textarea

おさらい含めて一旦ここまでのソースを下記に。

<html>
<head>
<title>サンプル・プログラム</title>
</head>
<body>
<form name="form1">
<p>テキスト格納フォルダ(フルパス)
<input type="text" name="fileaddr" value="c:\temp" /></p>
<p><input type="button" value="テキスト内容"
onClick="go_list()" /></p>
<textarea name="result" cols="80" rows="30" wrap=off></textarea>
<p><input type="reset" value="テキスト内容の初期化"></p>
<p><input type="button" value="終了" onClick="window.close()" /></p>
</form>
<script language="VBScript">
'テキスト内容ボタンクリック時
Sub go_list()

' MsgBox "テキスト内容ボタンが押されました。"

Call GET_FileName

End Sub

' ファイル一覧取得
Sub GET_FileName()

Dim WshShell, oExec
Dim strTemp

Set WshShell = CreateObject("WScript.Shell")

' dirコマンドの実行
exCommand = "cmd /c dir /o"
exCommand = exCommand & " " & document.form1.fileaddr.value & "\*.*"
Set oExec = WshShell.Exec(exCommand)

Do Until oExec.StdOut.AtEndOfStream
strTemp = strTemp & oExec.Stdout.ReadLine() & vbCrLf

Loop

' MsgBox strTemp
document.form1.result.value = strTemp

End Sub

</script>
</body></html>