Solved

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

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

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)…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

737 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