フォームを使ったVBAマクロの例
'****************************************************************
'
' 土石流対策指針(案)でのピーク流量
'
'****************************************************************
Option Explicit
Dim re As Double '有効降雨強度(mm/hr)
Dim rt As Double '洪水到達時間内の降雨強度(mm/hr)
Dim r24 As Double '24時間雨量or日雨量
Dim tp As Double '洪水到達時間(hr)
Dim qe As Double , qae As Double '流量(m3/sec)、比流量(m3/sec/km2)
Dim a As Double, f As Double '流域面積(km2)、ピーク流出係数(0.75〜0.85)
Private Sub UserForm_Initialize()
TextBox1 = ""
TextBox2 = ""
TextBox3 = ""
TextBox4 = ""
TextBox5 = ""
TextBox6 = ""
TextBox7 = ""
TextBox8 = ""
End Sub
Private Sub CommandButton1_Click()
'テキストボックスクリア
TextBox4 = ""
TextBox5 = ""
TextBox6 = ""
TextBox7 = ""
TextBox8 = ""
'=====================条件読み込み====================
a = Val(TextBox1)
f = Val(TextBox2)
r24 = Val(TextBox3)
'====================計 算==========================
'土研式有効降雨強度
re = (r24 / 24) ^ 1.21 * (24 * f ^ 2 / (120 / 60 * a ^ 0.22)) ^ 0.606
'洪水到達時間
tp = 120 * a ^ 0.22 * re ^ (-0.35) / 60
'平均降雨強度
rt = r24 / 24 * (tp / 24) ^ (-1 / 2)
'ラショナル式
qe = 0.2778 * re * a
'比流量
qae = qe / a
'===================出 力===========================
TextBox4 = Format(tp, "#.##") '洪水到達時間hr
TextBox5 = Format(rt, "#.##") '降雨強度mm/hr
TextBox6 = Format(re, "#.##") '有効降雨強度mm/hr
TextBox7 = Format(qe, "#.##") 'ピーク流量m^3/s
TextBox8 = Format(qae, "#.##") '比流量m^3/s/km^2
End Sub