VB.NET Unable passing String value

  • Thread starter Thread starter o1j2m3
  • Start date Start date
O

o1j2m3

I created 2 forms, A and B using VB.NET 2003

in A, the codes are :
==========================
public AsName as string
public AsPrice as double

public sub setValue(ByVal sname as string, ByVal price as double)
AsName = sname
AsPrice = price
end sub

private sub button0_click(...)
Dim frm as B
B.setParent(Me)
B.showDialog()
MsgBox(AsName) 'give me empty value, it should have value ***
MsgBox(AsPrice) 'give me empty value, it should have value ***
end sub
==========================

in B, the codes are :
==========================
public frmParent as A

public sub setParent(ByRef s as A)
frmParent = s
end sub

private sub button1_click(...)
frmParent.setValue("ddd",99.99) 'A values disappear once the B
closed
close()
end sub

private sub B_activated(...)
frmParent.setValue("ddd",99.99) 'A values maintained correct once
the B closed
close()
end sub



==========================

When I using F8 to trace... I found that, although the codes in
B_activated and button1_click are the same, but their behavior looks
different. B_activated provide me the correct output when I return to
A, but button1_click provide me wrong output.

During button1_click, when B is opening, the values(AsName,AsPrice) in
A are correct; Once B is closed, the values(AsName,AsPrice) in A will
automatic become empty and zero.

Anybody help? Because I need to pass the values within forms
frequently, but I have this problem? Any solution? Is this problem
solved in Service Pack already?

Urgent.. Thank You.
 
Hi,

I have not had any problems passing values between forms.
Usually I add a public property to a form for passing a value. In your code
I do not see where you ever call setvalue to give asname and asprice a
value.

Ken
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top