Solved

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

Posted on 2014-10-09
2
253 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 34

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

Tutorials alone can't teach real engineering

So we built better training tools.

-Hands-on Labs
-Instructor Mentoring
-Scenario-Based Tests
-Dedicated Cloud Servers

All at your fingertips. What are you waiting for?

Question has a verified solution.

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

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

695 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