Solved

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

Posted on 2014-10-09
2
247 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

713 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