Sub solid_s_get(tmp, s) temp = tmp & " 0 0" s = 0 a = Split(temp) If UBound(a) = 8 Then a(7) = a(1): a(8) = a(2) If UBound(a) >= 8 And a(0) = "sl" Then x0 = Val(a(1)) '各座標を格納 x1 = 0 x2 = (a(3) - x0) / 1000 x3 = (a(5) - x0) / 1000 x4 = (a(7) - x0) / 1000 y0 = Val(a(2)) y1 = 0 y2 = (a(4) - y0) / 1000 y3 = (a(6) - y0) / 1000 y4 = (a(8) - y0) / 1000 la1 = Sqr((x1 - x2) ^ 2 + (y1 - y2) ^ 2) la2 = Sqr((x2 - x3) ^ 2 + (y2 - y3) ^ 2) la3 = Sqr((x3 - x4) ^ 2 + (y3 - y4) ^ 2) la4 = Sqr((x4 - x1) ^ 2 + (y4 - y1) ^ 2) la5 = Sqr((x3 - x1) ^ 2 + (y3 - y1) ^ 2) sh1 = (la1 + la2 + la5) / 2 s1 = Sqr(sh1 * (sh1 - la1) * (sh1 - la2) * (sh1 - la5)) sh2 = (la3 + la4 + la5) / 2 s2 = Sqr(sh2 * (sh2 - la3) * (sh2 - la4) * (sh2 - la5)) s = s1 + s2 End IfEnd Sub
※使用例
tmp = jwc_temp_txt.readline
s=0
call solid_s_get(tmp, s)
tmpにはjwc_temp.txtから読み込んだ1行を代入する
sは戻り値を得るためのダミーとして0値を代入しておく