Solved

vb.net pause, get a value then continue with the execution

Posted on 2014-10-09
2
244 Views
Last Modified: 2014-10-09
I have the following partial code:

Public Class Form1

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        Dim cnn As SqlConnection = New SqlConnection
        frmInput.Show()
        Dim strUserOption As String = fnGetUserOption()

        Try
.
.
    End Sub

    Private Function fnGetUserOption() As String
        Dim userInput As New GetUserInputMME
        Return userInput.InputVal
    End Function

Question: How do I pause and restart the code execution when the form frmInput opens up and then closes?

Form frmInput has a listbox on it to allow the user to choose an option from it and then click on btnContinue.

The code in this form is:
Public Class frmInput
    Private Sub btnContinue_Click(sender As Object, e As EventArgs) Handles btnContinue.Click

        Dim userInput As New GetUserInputMME
        '
        'MessageBox.Show(userInput.InputVal)

        For l_index As Integer = 0 To ListBox1.Items.Count - 1
            'If ListBox1(l_index).SelectedItem Then
            'Dim l_text As String = CStr(ListBox1.Items(l_index))
            userInput.InputVal = "xyz" = userInput.InputVal
            ' End If
        Next
    End Sub
End Class

Open in new window

0
Comment
Question by:Mike Eghtebas
2 Comments
 
LVL 33

Assisted Solution

by:it_saige
it_saige earned 100 total points
ID: 40371627
You want to use ShowDialog instead of Show.

-saige-
0
 
LVL 40

Accepted Solution

by:
Kyle Abrahams earned 400 total points
ID: 40371628
frmInput.ShowDialog()

Will freeze the execution and wait for it to close.

Then you just need a public variable on form one or create a
public static class and assign the variable.

eg:

public static class SharedVars

public Static UserInput as String

end class


Then in your Dialog:

SharedVars.UserInput = "xyz"

then in your form1
SharedVars.UserInput
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question