It had to replace a defective harddisk, so I could not reply any sooner.
I could reproduce this behavior in a small new project.
I also discobvered wahat I did wrong, although I still don't quite
understand it.
I passed the parameter from FormA to FormB as follows:
Private Parm as string
dim myFormb as New FormB(Parm)
FormB.Show
In FormB:
Private Filename as string
..
Public Sub New(byval Filename as string)
Filename = Filename
etc.
Public Sub Form2_Load .....
xxxx = Filename
Now filename appears to be empty (Nothing)
when I change the code to"
Private myFilename as string
..
Public Sub New(byval Filename as string)
myFilename = Filename
etc.
Public Sub Form2_Load .....
xxxx = myFilename
then everything is fine.
as I said, I don't quite understand, but it works.
Best regards, Jan Warning
"Zoury" <yanick_lefebvre at hotmail dot com> wrote in message
news:ug******************@TK2MSFTNGP14.phx.gbl...
Yeah.. Your original would have been better... Was it the real code
(copy/paste) ? If so can you reproduce this behavior in a new project ?
--
Best Regards
Yanick
"Jan Warning" <ja*********@wanadoo.nl> a écrit dans le message de
news:On*************@TK2MSFTNGP15.phx.gbl... I tried it (I noticed your mistake) and it worked. Thanks a lot.
But I am still wondering why my original code did not work.
Regards, Jan Warning
"dotnetnewbie" <do**********@discussions.microsoft.com> wrote in message
news:5B**********************************@microsof t.com... > Correction to my last post
>
> Dim frm as FormB
>
> should have read
>
> Dim frm as New FormB
>
> Gerry
>
>
> "Jan Warning" wrote:
>
>> How do I pass an argument from one form to another?
>> I do the following:
>> FormA:
>> dim strFilename as string ="Filename"
>> dim frmLayout1 as New frmLayout(strFilename)
>> frmLayout1.Show()
>>
>> frmLayout:
>> Private strFilename as string
>> ..
>> ..
>> Sub New(Filename as string)
>> ..
>> ..strFilename = Filename
>> ..
>> ..
>> Private Sub frmLayout_Load(...)
>> dim strLayout as new Filestream(strFilename, FileMode.Open)
>>
>> At this point I get an error because strFilename is empty (Nothing)
>>
>> When I step thru the code, I can see that the parm is correctly passed to >> and stored by the Sub New
>> What am I doing wrong?
>>
>>
>>
>>