• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 185
  • Last Modified:

How do I accept a User Input from multiple forms using the same "Input form"?

I want to have the user be able to click in any text box and when they do, a "User Input" keyboard will pop-up and they can Enter in a value (the program is going to be running on a touch screen with no keyboard, so on-screen keyboard is required). The value they enter will appear in a text box on the "User Input" form. When they hit accept, I want that value to be transfered to the textbox on the form in which they originally clicked in. I want the "User Input" keyboard to be able to be used multiple times throughout the program, and Ideally I just want to have to call a sub-routine or function when the user "Enters" the text box in which they want to type in.

I have tried this multiple ways and can't seem to get it working correctly. It kind of works, but not like I would hope.  I wish I still had my original code, but i have been tinkering with it; and It's pretty messed up at the moment. A basic concept of what i was doing is:


txt_textbox (on Enter event)

txt_textbox.text = Module1.UserInput


Public UserInputValue as String

Public Function UserInput

frm_Userinput.TopMost = True

UserInput = UserInputValue

UserInputValue = Nothing

End Function



UserInputValue = txt_Value.Text
txt_Value.Text =""


This would work kind of. It was like it would sometimes work and others not. Especially the first textbox i would try would usually fail. The textboxes after that seemed to work just fine.

I know there is an easy way of doing what I'm trying to do, Any ideas/suggestions?
  • 3
  • 2
1 Solution
Gssc1414Author Commented:
Or at least I would think there is an easy way, and im just thinking too much into it.
Gssc1414Author Commented:
Hmm... I think i may have figured out a good way of doing it.

1. Defined a "textbox" variable publically.

2. Set the variable to the texbox that i want text to appear in.

3. Set the Variables ".text" property when the user hits the accept button to what is in the UserInput text box.

Below is my code:

Is this a good/recommeneded way of doing it?
    Private Sub txt_CurrentBladeRPM_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txt_CurrentBladeRPM.Enter
        txtBox = Me.txt_CurrentBladeRPM
    End Sub
Module SAW
    Public SupervisorLoginCache As Boolean
    Public LoggedInUser As String
    Public UserInputValue As String
    Public txtBox As TextBox
End Module
    Private Sub btn_Accept_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_Accept.Click
        txtBox.Text = txt_Value.Text
        txt_Value.Text = ""
    End Sub

Open in new window

What I'd reccoment is...
 a global variable on the "UserInput" form
    Public pub_userInput as string=""

 Private Sub btn_Accept_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_Accept.Click
        txtBox.Text = txt_Value.Text
        pub_userInput= txt_Value.Text  '//assuming this is the value your user has typed.
    End Sub

And you can use it like (from any form)

    Public Function getFormInput() As String
        Dim myText As String = ""

        Dim f As New formUserInput  '// assuming formUserInput is the form name
        myText = f.pub_userInput  '// myText has the value of the user input

        If myText Is DBNull.Value Then myText = ""
        Return myText
    End Function
Gssc1414Author Commented:
Is there any benefit to do it the way you posted it over the solution I came upon above, or is it just the way that your used to / makes most since to you?

Thanks for the response, I am just wondering if there are any benefits (performance/scalability ect.) to your method.
Whatever fits you.
I find the way I posted easier to debug in the future.

Take care
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now