I am new to VB and am struggling a bit. I am using VB 2005 Express and have created a backgroundWorker to copy some large files and it is working fine, however, I need to pass a value in to the BackgroundWorker or get it to read a value in Form1 that I have open.

My Form (AcademyLauncherSyncroTool) has a combo box, the value chosen in the combo box forms part of a drive path that I am using in a 'CopyDirectory' command. I have BackgroundWorker1 doing the file copy for me so need to get the chosen combo value to create the SourcePath for my CopyDirectory. The code I have is:

Dim RelVal, SourceDir, DestDir as string

Dim zF1 as New AcademyLauncherSyncroTool

RelVal = zF1.AcademyRel.text ' AcademyRel is the name of my combo box

SourceDir = ("X:\AcademyClientProducts\Local Instalation\" & RelVal & "\ACP")

DestDir = ("C:\Program Files\AcademyClientProducts\ACP")

My.Computer.FileSystem.CopyDirectory(SourceDir, DestDir)

When I try this, the 'RelVal' value is the default text value of textbox9 on zF1 and not the value chosen by the user. This code is wrong but essentially what I want is:

BackgroundWorker1_DoWork(ByVal GivenRunVal as string)

SourceDir="X:\AcademyClientProducts\Local Instalation" & GivenRunVal & "\ACP")

DestDir = "C:\Program FIles\AcademyClientProducts\ACP"

My.Computer.FileSystem.CopyDirectory(SourceDir, DestDir)

I hope this makes sense, and I would appreciate any help on this. I am sure its dead simple once you know how, but I am struggling.

Re: Visual Basic General VB Get value from another form


If anybody was looking at this to offer a solution, please dont waste your time. I have now managed to resolve this. I went and had a coffee, then came back and realised that this work sort it.

In Form1:

dim MyVal as string

MyVal = textbox1.text


In BackgroundWorker1:

dim GotTheVal as string

GotTheVal = e.Argument.ToString

Thanks to anybody who was preparing an answer, and humble apologies for my stupidity :-)