Welcome to the RAS Solution Forums HECRAS Controller Multi-run using VB.NET

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #8190
    Anonymous
    Guest

    Here is a code to run a set of plan-file in HECRAS.
    The code is written in VB.NET.
    You need create a form, insert a TextBox (where you have to insert the pathfilename of the HECRAS project), a listBox to view the plans contained in the project, and two buttons.

    Public Class FormHECRAS
    Dim RC As New RAS503.HECRASController
    Dim filename As String

    Private Sub FormHECRAS_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
    CmdRUN.Enabled = False
    End Sub

    Private Sub CmdRUN_Click(sender As System.Object, e As System.EventArgs) Handles CmdRUN.Click
    ComputeAllPlans()
    End Sub

    Private Sub CmdLoadPlan_Click(sender As System.Object, e As System.EventArgs) Handles CmdLoadPlan.Click
    Dim PlanCount As Long
    Dim PlanNames As System.Array = Array.CreateInstance(GetType(String), {0}, {1})
    ‘Dim PlanNames As System.Array = Array.CreateInstance(GetType(String), 0)
    Dim RC As New RAS503.HECRASController
    filename = TextBoxFilename.Text
    RC.Project_Open(filename)
    RC.Plan_Names(PlanCount, PlanNames, True)
    ListBoxPlans.Items.Clear()
    For Each p As String In PlanNames
    ListBoxPlans.Items.Add(p)
    Next p
    CmdRUN.Enabled = True
    End Sub

    Sub ComputeAllPlans()
    Dim didItCompute As Boolean
    Dim nMessages As Long
    Dim Messages As System.Array = Array.CreateInstance(GetType(String), {0}, {1})
    RC.Project_Open(filename)
    For Each p As String In ListBoxPlans.SelectedItems
    RC.Plan_SetCurrent(p)
    didItCompute = RC.Compute_CurrentPlan(nMessages, Messages)
    Next p
    RC.Project_Close()
    End Sub
    End Class

    #13532
    Chris G.
    Keymaster

    Thanks for sharing!

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.