Solved

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

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

Assisted Solution

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

-saige-
0
 
LVL 39

Accepted Solution

by:
Kyle Abrahams earned 400 total points
Comment Utility
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
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.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

772 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now