Hi All,
I'm currently trying to update this Microsoft Basic code into VBA. Is it possible? I have no idea with coding however have pasted a copy of the code below. It basically is to do with gutter flow times during storm events however I like to get it to work so i can use it to save a whole lot of time. I had an attempt at converting it however im walking blindly here.
I'm currently trying to update this Microsoft Basic code into VBA. Is it possible? I have no idea with coding however have pasted a copy of the code below. It basically is to do with gutter flow times during storm events however I like to get it to work so i can use it to save a whole lot of time. I had an attempt at converting it however im walking blindly here.
Code:
Rem Gutter and Roadway Flow Characteristics Program
Rem (In Microsoft Basics)
Debug.Print "Gutter and Roadway Flow Characteristics Program"
Debug.Print "Gutter Width (m), Half Road Width (m)?"
Input #1, GW, PW
Debug.Print "Gutter and Pavement Cross Slopes (m/m)?"
Input #2, GS, PS
Debug.Print "Gutter Face Slope (Degrees, 0 - Flat, 90 -Vertical)?"
Input #3, Theta
Debug.Print "Gutter Depth (m)?"
Input #4, GD
GS = GD / (GD / Tan(0.0174533 * Theta) + GD / GS)
If Theta = 90 Then GoTo 17
Debug.Print "Revised Gutter Cross Slope"
Debug.Print using; "Due to Sloping Face Is##.#####"; GS
Debug.Print "Gutter and PAvement Roughness?"
Input #5, GN, PN
Debug.Print "Flowrate Adjustment Factor?"
Input #6, F
Debug.Print "Longitudinal Slope (m/m)?"
Input #7, LS
Debug.Print "Gutter Length (m)?"
Input #8, Length
Rem - The Gutter Capacity is Calculated for the given depth
PD = GD - GW * GS
If PD < 0 Then PD = 0
CD = PD - (PW - GW) * PS
If CD < 0 Then CD = 0
X = 8 / 3
Q = 0.375 * F * ((GD ^ X - PD ^ X) / (GS * GN) + (PD ^ X - CD ^ X) / (PS * PN)) * LS ^ 0.5
Debug.Print using; "Capacity at Given Depth is###.### m^3/s"; Q
Debug.Print
Rem - Now the user can nominate a flowrate and the program will determine flow depth, width and velocity
Debug.Print
CC = 1
Debug.Print "Trial flowrate (m^3/s)? Zero for new slope, -ve to end"
Rem Program Goes back if Zero is Entered
Input #9, Q1
If Q1 < Q Then GoTo 75
If Q1 = 0 Then GoTo 21
If Q1 > Q Then Debug.Print "Note that flow exceeds capacity"
If Q1 > Q Then Debug.Print "- Calculations ignore flow on footpaths"
TD = GD * (Q1 / Q) ^ (1 / X)
Rem Start of Iterations
PD = TD - GW * GS
CD = PD - (PW - GW) * PS
If CD < 0 Then CD = 0
If PD < 0 Then PD = 0
Q2 = 0.375 * F * ((TD ^ X - PD ^ X) / (GS * GN) + (PD ^ X - CD ^ X) / (PS * PN) * LS ^ 0.5)
If Abs(Q1 - Q2) < 0.00001 Then GoTo 55
CC = CC + 1
TD = TD * (Q1 / Q2) ^ (1 / X)
GoTo 56
TW = TD / GS
If TW > GW Then TW = GW + (PD / PS)
AREA = TD * TW / 2
If TW > GW Then AREA = GW * (TD + PD) / 2 + PD * PD / PS / 2
If TW <= PW Then GoTo 62
AREA = AREA - CD * CD / PS / 2
TW = PW
Debug.Print using; "results after ## iterations :"; CC
Debug.Print using; "Flow Area is##.### m^2;AREA"
Debug.Print using; "width is###.## m"; TW
Debug.Print using; "Gutter Depth is##.### m"; TD
If CD > 0 Then Debug.Print using; " Crest Depth is ##.### m"; CD
V = Q1 / AREA
Debug.Print using; "velocity is ###.## m/s"; V
Debug.Print using; "Velocity-Depth Product is ##.##"; TD * V
Time = Length / V
TM = Time / 60
Debug.Print using; "Time is ####=(##.## minutes;)"; Time, TM
Debug.Print
GoTo 36
End