Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
85 views6 pages

Graphicswindow Graphicswindow: Height Width

The document contains code for a Small Basic program that allows users to design trapezoidal and rectangular channel cross-sections. It includes subroutines to: 1) Display a main menu with option buttons for different channel designs 2) Perform calculations for a trapezoidal channel design based on user input parameters 3) Perform calculations for a rectangular channel design based on user input parameters The program displays input boxes, output boxes and buttons to trigger calculations for various channel properties.

Uploaded by

ryeue
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
85 views6 pages

Graphicswindow Graphicswindow: Height Width

The document contains code for a Small Basic program that allows users to design trapezoidal and rectangular channel cross-sections. It includes subroutines to: 1) Display a main menu with option buttons for different channel designs 2) Perform calculations for a trapezoidal channel design based on user input parameters 3) Perform calculations for a rectangular channel design based on user input parameters The program displays input boxes, output boxes and buttons to trigger calculations for various channel properties.

Uploaded by

ryeue
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Lester Jr. L.

Aspilan
AE – 713 Basic Programming

Command in Small Basic

mainmenu()
GraphicsWindow.Height = 500
GraphicsWindow.Width = 600

Sub mainmenu
GraphicsWindow.Height = 1200
GraphicsWindow.Width = 600
GraphicsWindow.Show()
GraphicsWindow.Title = "Channel Design Calculation"
Controls.ButtonClicked = whichbutton

butTrapezoidal = Controls.AddButton("Trapezoidal Channel


Design",25,25)

butRectangular = Controls.AddButton("Rectangular Channel Design",


25,120)

butParabolic = Controls.AddButton("Parabolic Channel Design",


25,220)

butCancel = Controls.AddButton("Cancel",350,350)

Controls.ButtonClicked= anybutton

EndSub

Sub anybutton
linker= Controls.LastClickedButton

If linker= butTrapezoidal Then


trapezoidalanalysis()

ElseIf linker= butRectangular then


rectangularbutton()
EndIf
EndSub

Sub trapezoidalanalysis
GraphicsWindow.Clear()
GraphicsWindow.BrushColor = "Dark"
GraphicsWindow.DrawText(25, 25,"Side Slopes")
GraphicsWindow.DrawText(50, 45,"Z1:")
Z1box = Controls.AddTextBox(75,41)
GraphicsWindow.DrawText(50, 75,"Z2:")
Z2box = Controls.AddTextBox(75,72)

GraphicsWindow.DrawText(25, 100,"Water Depth")


GraphicsWindow.DrawText(57, 121,"Y:")
Ybox = Controls.AddTextBox(75,119)

GraphicsWindow.DrawText(25, 150,"Bottom Width")


GraphicsWindow.DrawText(57, 173,"b:")
bbox = Controls.AddTextBox(75,170)

GraphicsWindow.DrawText(25, 200,"Manning Roughness")


GraphicsWindow.DrawText(57, 220,"n:")
nbox = Controls.AddTextBox(75,218)

GraphicsWindow.DrawText(25, 240,"Channel Slope")


GraphicsWindow.DrawText(57, 262,"S:")
Sbox = Controls.AddTextBox(75,260)

butCalculate = Controls.AddButton("Wetted Perimeter",315,5)


Calculation = Controls.AddMultiLineTextBox(315, 30)
Controls.SetSize(Calculation, 150, 25)

butTCalculate = Controls.AddButton("Top Width",315,65)


CalculationT = Controls.AddMultiLineTextBox(315, 90)
Controls.SetSize(CalculationT, 150, 25)

butACalculate = Controls.AddButton("Area",315,125)
CalculationA = Controls.AddMultiLineTextBox(315, 150)
Controls.SetSize(CalculationA,150,25)

butHCalculate = Controls.AddButton("Hydraulic Radius",315,185)


CalculationH = Controls.AddMultiLineTextBox(315, 210)
Controls.SetSize(CalculationH,250,25)

butVCalculate = Controls.AddButton("Velocity",315,240)
CalculationV = Controls.AddMultiLineTextBox(315, 265)
Controls.SetSize(CalculationV,250,25)

butQCalculate = Controls.AddButton("Discharge",315,295)
CalculationQ = Controls.AddMultiLineTextBox(315, 320)
Controls.SetSize(CalculationQ,250,25)
butTetaCalculate = Controls.AddButton("Angle",315,350)
CalculationTeta = Controls.AddMultiLineTextBox(315, 375)
Controls.SetSize(CalculationTeta,250,25)

butFCalculate = Controls.AddButton("Froude Number",315,405)


CalculationF = Controls.AddMultiLineTextBox(315, 430)
Controls.SetSize(CalculationF,250,25)

Controls.ButtonClicked= whichbutton

EndSub

Sub whichbutton
button = Controls.LastClickedButton

Z1 = Controls.GetTextBoxText(Z1box)
Z2 = Controls.GetTextBoxText(Z2box)
Y = Controls.GetTextBoxText(Ybox)
b = Controls.GetTextBoxText(bbox)
n = Controls.GetTextBoxText(nbox)
S = Controls.GetTextBoxText(sbox)

P = b + Y * ((Math.SquareRoot(1 + Math.Power(Z1,2))) +
(Math.SquareRoot(1 + Math.Power(Z2,2))))
T = b + Y * (Z1 + Z2)
A = Y/2 * (b + T)
R = A/P
V = ((Math.Power(R,2/3)) * (Math.Power(S,1/2)))/n
Q = V*A
Teta = (S*180)/Math.Pi
F = V * Math.SquareRoot((T/(Q*A *Math.Cos(Teta))))

If button = butCalculate Then


Controls.SetTextBoxText(Calculation, P)

ElseIf button = butTCalculate Then


Controls.SetTextBoxText(CalculationT, T)

ElseIf button = butACalculate Then


Controls.SetTextBoxText(CalculationA, A)

ElseIf button = butHCalculate Then


Controls.SetTextBoxText(CalculationH, R)

ElseIf button = butVCalculate Then


Controls.SetTextBoxText(CalculationV, V)

ElseIf button = butQCalculate Then


Controls.SetTextBoxText(CalculationQ, Q)

ElseIf button = butTetaCalculate Then


Controls.SetTextBoxText(CalculationTeta, Teta)

ElseIf button = butFCalculate Then


Controls.SetTextBoxText(CalculationF, F)

EndIf

EndSub

Sub rectangularbutton

linkerR= Controls.LastClickedButton

If linkerR= butRectangular Then


rectangularanalysis()

EndIf
EndSub

Sub rectangularanalysis

GraphicsWindow.Clear()
GraphicsWindow.BrushColor = "Dark"

GraphicsWindow.DrawText(25, 25,"Water Depth")


GraphicsWindow.DrawText(57, 52,"Y:")
RYbox = Controls.AddTextBox(75,49)

GraphicsWindow.DrawText(25, 90,"Bottom Width")


GraphicsWindow.DrawText(57, 118,"b:")
Rbbox = Controls.AddTextBox(75,115)

GraphicsWindow.DrawText(25, 155,"Manning Roughness")


GraphicsWindow.DrawText(57, 182,"n:")
Rnbox = Controls.AddTextBox(75,180)

GraphicsWindow.DrawText(25, 220,"Channel Slope")


GraphicsWindow.DrawText(57, 250,"S:")
RSbox = Controls.AddTextBox(75,248)
butRACalculate = Controls.AddButton("Area",315,25)
CalculationRA = Controls.AddMultiLineTextBox(315, 50)
Controls.SetSize(CalculationRA,250,25)

butRWPCalculate = Controls.AddButton("Wetted Perimeter",315,102)


CalculationRWP = Controls.AddMultiLineTextBox(315, 127)
Controls.SetSize(CalculationRWP,250,25)

butRHRCalculate = Controls.AddButton("Hydraulic Radius",315,177)


CalculationRHR = Controls.AddMultiLineTextBox(315, 202)
Controls.SetSize(CalculationRHR,250,25)

butRVCalculate = Controls.AddButton("Velocity",315,250)
CalculationRV = Controls.AddMultiLineTextBox(315, 275)
Controls.SetSize(CalculationRV,250,25)

butRVCalculate = Controls.AddButton("Discharge",315,325)
CalculationRV = Controls.AddMultiLineTextBox(315, 350)
Controls.SetSize(CalculationRV,250,25)

Controls.ButtonClicked= rectangularwhichbutton

EndSub

Sub rectangularwhichbutton
Rbutton = Controls.LastClickedButton

RY = Controls.GetTextBoxText(RYbox)
Rb = Controls.GetTextBoxText(Rbbox)
Rn = Controls.GetTextBoxText(Rnbox)
RS = Controls.GetTextBoxText(RSbox)

A = (RY) * (Rb)
P = (2*RY) + Rb
R = A/P

If Rbutton = butRACalculate Then


Controls.SetTextBoxText(CalculationRA, A)

ElseIf Rbutton = butRWPCalculate Then


Controls.SetTextBoxText(CalculationRWP, P)

ElseIf Rbutton = butRHRCalculate Then


Controls.SetTextBoxText(CalculationRHR, R)

ElseIf Rbutton = butRVCalculate Then


Controls.SetTextBoxText(CalculationRV, V)

EndIf
EndSub

You might also like