Get the TextBox.Text from within thread

Peter Volz 1,295 Reputation points
2023-04-05T02:48:56.9166667+00:00

Hello all, Is this correct to get the text inside a TextBox from within thread? Private Delegate Function GetDSPNCallback() As String Private Function GetDSPN() As String If DTextBoxX.InvokeRequired Then Invoke(Sub() GetDSPN = DTextBoxX.Text.Trim) Else GetDSPN = DTextBoxX.Text.Trim End If End Function Thank you

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,408 questions
VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,610 questions
0 comments No comments
{count} votes

Accepted answer
  1. Viorel 113.2K Reputation points
    2023-04-05T05:39:03.27+00:00

    Check this:

    Private Function GetDSPN() As String
        Dim t As String = Nothing
        Invoke(Sub() t = DTextBoxX.Text.Trim)
        Return t
    End Function
    
    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful