0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

vbsの作法 その93

Posted at

概要

vbsの作法、調べてみた。
練習問題やってみた。

練習問題

sin波をIE11で表示せよ。

写真

image.png

サンプルコード


Class ohicompo1
	Private objIE
	Private Sub Class_Initialize
		Set objIE = CreateObject("InternetExplorer.Application")
		objIE.Visible = true
		objIE.Top = 100
		objIE.Left = 100
		objIE.Width = 500
		objIE.Height = 600
		objIE.Navigate("about:blank")
		objIE.StatusBar = False
		objIE.ToolBar = 0
		objIE.Document.Write "<html><head><title>ohicompo1</title></head><body>"
		objIE.Document.Write "<canvas id='canvas' width='300' height='300'></canvas>"
		objIE.Document.Write "<input id='btn' type='submit' value='run' onclick='run()'><br>"
		objIE.Document.Write "<textarea id='src'rows='20' cols='30'></textarea>"
		objIE.Document.Write "<script type='text/javascript'>"
		objIE.Document.Write "var src = document.getElementById('src');"
		objIE.Document.Write "var canvas = document.getElementById('canvas');"
		objIE.Document.Write "var ctx = canvas.getContext('2d');"
		objIE.Document.Write "function draw(data) {"
		objIE.Document.Write "    ctx.strokeStyle = '#f0f';"
		objIE.Document.Write "    ctx.lineWidth = 2;"
		objIE.Document.Write "    ctx.moveTo(0, 150);"
		objIE.Document.Write "    for (var i = 1; i < canvas.width; i++)"
		objIE.Document.Write "    {"
		objIE.Document.Write "        ctx.lineTo(i, 150 - data[i] * 30);"
		objIE.Document.Write "    }"
		objIE.Document.Write "    ctx.stroke();"
		objIE.Document.Write "}"
		objIE.Document.Write "function run() {var data = [];var line = src.value.split(' ');for (var i = 0; i < line.length; i++){data.push(line[i]);}draw(data);}"
		objIE.Document.Write "</script></body></html>"
	End Sub
	Private Sub Class_Terminate
	End Sub
	Public Sub text(str)
		objIE.Document.getElementById("src").InnerText = str
	End Sub
	Public Sub run()
		objIE.Document.getElementById("btn").Click()
	End Sub
	Public Sub owari()
		objIE.Quit
	End Sub
End Class

Dim str
str = ""
Dim ds
Dim s
Dim i
ds = 220 * 2 * 3.1415 / 8000
s = 0
for i = 0 to 300
	v = Sin(s)
	str = str + CStr(v) + " "
	s = s + ds
next
Dim w1
Set w1 = new ohicompo1
w1.text str
w1.run







以上

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?