Passing strings from one Form to another in Visual Basic Express 2008?

SpaceshipSpaceship
Namecheap AuctionsNamecheap Auctions
SpaceshipSpaceship
Watch

FPForum

Top Member
Impact
1,436
I am using a TextBox control on one form to accept a directory name and trying to use it on a second form to find the number of files in that directory

(filecnt = My.Computer.FileSystem.GetFiles(Form1.txtLocallyArchivedJpg). I receive the following error whenever I try and use the directory entered in the TextBox “Value of type 'System.Windows.Forms.TextBox' cannot be converted to 'String'”

How can I get rid of this error?
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
Unstoppable Domains — AI StorefrontUnstoppable Domains — AI Storefront
It would be good that you post some code.

Assuming that in the second form you already have a reference set to Form1 you could get the value of the string entered in the textbox like this (in Form2)
Code:
filecnt = Form1.txtDirectory.Text
where txtDirectory is the textbox name

A better way would consist in passing the string as a parameter to Form2 using Overload methods.
Example: How To Pass Data Between Forms in VB.NET
 
1
•••
Got it figured out sds! Thanks
 
0
•••
Truehost — .com domains from $4.99, hosting includedTruehost — .com domains from $4.99, hosting included

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com
Catchy
DomDB
NameFit
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back