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

Namecheap AuctionsNamecheap Auctions
SpaceshipSpaceship
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.
GoDaddyGoDaddy
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
•••
DomainEasy: flexible LTO options. Close more domain deals with financing.

We're social

Escrow.com
Spaceship
Escrowly
CryptoExchange.com
Domain Recover

NamePros updates

Parking: find your domains by pasting a list
You can now paste a list of domain names into the search box at the top of the Parking menu. Put one name on each line. Your domain list...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back