Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5849391
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:59:34+00:00 2026-05-22T12:59:34+00:00

In my vb program, I have two forms that work together to allow you

  • 0

In my vb program, I have two forms that work together to allow you to define an almost arbitrary amount of designs. In the first form, there is a two-dimensional array, storing an integer (not important) and an ID class that I defined as a public inner class in another form. Clicking on the “Define ID” button in this form will take you to the next form, where you will define a new ID or edit an old one based off of an index in the array you selected or entered in the first form’s combo box, using multiple fields in the second form to define its different aspects. What I want to happen is the first form’s code to be suspended as the user defines the ID in the second form, then they click on the Continue button on the second form. After a bit of error-checking, the form either is momentarily hidden (which is how I originally implemented it) or returns the edited ID object, but only if the error-checking does not indicate any input is incorrect. Originally, I simply grabbed the ID by using newForm.curID and set that to its spot in the array, waiting for the user to finish by using newForm.showDialog(), but sometimes the program would return a null exception because I don’t think I copy the IDs correctly. Also, though the errors show up for a small amount of time, the Continue button saves the ID regardless of its correctness. Is there a way to manipulate the showDialog to get a result response out of it?

Short version: I need to either return an object of an inner class in one form to an array in a calling form or wait for a form to finish and use the calling form to copy its object, then close the callee form.

First Form’s “Define” button method

Private Sub DesignButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DesignButton.Click
    Me.totalCoilBox.Focus() 'calls validating method, makes textbox yellow if invalid'

    If totalCoilBox.BackColor = Color.White Then
        Dim newForm As New IVD_DesignData 'creates an object of ID called curID as well'

        Try
            If DesignIDBox.Items.Contains(DesignIDBox.Text) Then 'design exists
                set the curID to the one already in the array'
                newForm.curID = CGID(Integer.Parse(DesignIDBox.Text), 1)
                'set number of coils to new number, if applicable'
                CGID(Integer.Parse(DesignIDBox.Text), 0) = Integer.Parse(DesignIDBox.Text)

                'show dialog for editing'
                newForm.ShowDialog()
                'put the (edited) curID back into the array'
                CGID(Integer.Parse(DesignIDBox.Text), 1) = newForm.curID
            Else 'design does not exist, make a new one
                put number of coils into new array spot'

                CGID(Integer.Parse(DesignIDBox.Text), 0) = Integer.Parse(totalCoilBox.Text)
                'set the design ID to the number of defined IDs plus one'
                newForm.curID.designID = Integer.Parse(DesignIDBox.Text)
                'show dialog for editing'
                newForm.ShowDialog()
                'add curID into the array'
                CGID(Integer.Parse(DesignIDBox.Text), 1) = newForm.curID
                'add that design number to the dropdown box'
                DesignIDBox.Items.Add(newForm.curID.ToString())
                'increment number of defined designs'
                Current_IDBox.Text = Integer.Parse(Current_IDBox.Text) + 1
            End If

        Catch ex As ArgumentOutOfRangeException 'dropdown box has no elements in it;
            do the same as adding a new ID:
            put number of coils into new array spot'
            CGID(Integer.Parse(DesignIDBox.Text), 0) = Integer.Parse(totalCoilBox.Text)
            'set the design ID to the number of defined IDs plus one'
            newForm.curID.designID = Integer.Parse(DesignIDBox.Text)
            'show dialog for editing'
            newForm.showDialog()
            'add curID into the array'
            CGID(Integer.Parse(DesignIDBox.Text), 1) = newForm.curID
            'add that design number to the dropdown box'
            DesignIDBox.Items.Add(newForm.curID.ToString())
            'increment number of defined designs'
            Current_IDBox.Text = Integer.Parse(Current_IDBox.Text) + 1
        End Try
        DesignIDBox.Text = newForm.curID.ToString()
        newForm.Close()
    End If

Second Form’s “Continue” button method

Private Sub ContinueButton_Click(ByVal sender As System.Object, ByVal e As ByVal e As System.EventArgs) Handles ContinueButton.Click
    Me.NTBox.Focus()
    Me.IDBox.Focus()
    Me.ODBox.Focus()
    Me.TBox.Focus()
    Me.WBox.Focus()
    If HSCBox.Checked Then
        Me.HSC_MultBox.Focus()
    Else
        curID.HSC = "n"
        curID.HSC_Mult = 1
    End If

    If NTBox.BackColor = Color.White And IDBox.BackColor = Color.White And ODBox.BackColor = Color.White And TBox.BackColor = Color.White And WBox.BackColor = Color.White And ((HSCBox.Checked And HSC_MultBox.BackColor = Color.White) Or Not (HSCBox.Checked)) Then
        'success!  window falls back?'
    End If
End Sub

Thanks for any and all help! I’m much more proficient in Java, so this VB project is a bit frustrating sometimes.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T12:59:35+00:00Added an answer on May 22, 2026 at 12:59 pm

    On your second form, make a method like this:

    public function ReturnSomething(curId as whateverType) as whateverReturnType
    
      me.curId = curId
      me.showDialog
      return someValue
    
    end function
    

    then call that from your first form.

    EDIT: also, have your second form’s Continue method call Me.Close. This will close the second form. The ShowDialog call will block until the form is closed.

    The first form should not be calling the second form’s close method.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two simple while loops in my program that I feel ought to
Is tight looping in a program bad? I have an application that has two
I have a program with two TForm classes and have added a TMainMenu to
I have two (UNIX) programs A and B that read and write from stdin/stdout.
in a C program I have an long* that I want to serialize (thus
I have two forms a) post.php b) edit.php I am using the checkbox in
I would like a batch file to launch two separate programs then have the
I have recently been put in charge of debugging two different programs which will
Most program languages have some kind of exception handling; some languages have return codes,
In my program I have one array with 25 double values 0.04 When I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.