Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HELP!!! (LOL) Declaring Variable to = Textbox Value

Status
Not open for further replies.

txgeekgirl1

Programmer
Sep 10, 2009
85
0
0
US
I do not know why I am struggling so hard with this. I have gone online and found examples and it keeps throwing me an error that

Code:
Value of type 'String' cannot be converted to 'System.Windows.Forms.TextBox'.

I have two Public Vars as Str: MyFile and MyStaff in the Module1.vb file

This code is in Form1.vb

Code:
Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
        MyFile = Me.txFileName.Text
        MyStaff = Me.txStaffId.Text
        MsgBox(MyFile)
        'SaveDestFile()
    End Sub

These variables become the basis for a filter of MyFile. How do I clear that error and get this to work?

BTW - I know it's probably elementary - I code in VB about once a year and most of what we have are static mapped filecalls - so I am dumb here.
 
So you have something like this:
Code:
Module Module1
    [red]Public[/red] MyFile As [red]String[/red]
    [red]Public[/red] MyStaff As [red]String[/red]
End Module

Public Class Form1
    Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
        MyFile = Me.txFileName.Text
        MyStaff = Me.txStaffId.Text
        MsgBox(MyFile)
        'SaveDestFile()
    End Sub
End Class
And when you click the btnSubmit Button you get that error on the line "MyFile = Me.txFileName.Text"?

-I hate Microsoft!
-Forever and always forward.
-My kingdom for a edit button!
 
Thank you Sorwen - I just right before I got your email figured out I was mixing the call. Kept changing it to String but not adding the Text to the declaration or changed it to a Textbox and didn't add the Text to the msgbox.

Thank you so much.
 
Ah! NP. :)

-I hate Microsoft!
-Forever and always forward.
-My kingdom for a edit button!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top