Y
Young
Hi,
I am currently porting a VB6 app to VB.NET 2008 and am stucked big tim.
I've got 2 forms in VB.Net (Form1 and Form2) each with a public string
variable defined as Dim sv_str_1 as string.
I also got a Sub that accept a form and work on the variable.
Eg.
Sub DispValue(frm as form)
Msgbox frm.sv_str_1
End sub
This will display whatever is in sv_str_1 for the form. Eg.
1) If I call DispValue(Form1), it will display sv_str_1 for Form1
2) Calling DispValue(Form2) will display sv_str_1 from Form2.
This works in VB6 but not VB.Net.
In VB6, I can also do this:
Dim MyWorkForm as Form
Set MyWorkForm = Form1
Msgbox MyWorkForm.sv_str_1
This will display the string value for Form1.
In VB.NET, Msgbox MyWorkForm.sv_str_1 will generate an error when
compiling - it says sv_str_1 is not a member of System.Windows.Forms.Form.
This Msgbox Form1.sv_str_1 works in .NET because I did not assign Form1 to a
variable.
This is the same for accessing controls on a VB.NET form. For example, I can
do this in VB6:
Dim MyWorkForm as Form
Set MyWorkForm = Form1
Msgbox MyWorkForm.TextAdd.Text
This will display the value for textbox "TextAdd"
But same does not work in VB.NET. Same error. It says that TextAdd is not a
member of System.Windows.Forms.Form.
Is there a way around this?
TIA
Young
I am currently porting a VB6 app to VB.NET 2008 and am stucked big tim.
I've got 2 forms in VB.Net (Form1 and Form2) each with a public string
variable defined as Dim sv_str_1 as string.
I also got a Sub that accept a form and work on the variable.
Eg.
Sub DispValue(frm as form)
Msgbox frm.sv_str_1
End sub
This will display whatever is in sv_str_1 for the form. Eg.
1) If I call DispValue(Form1), it will display sv_str_1 for Form1
2) Calling DispValue(Form2) will display sv_str_1 from Form2.
This works in VB6 but not VB.Net.
In VB6, I can also do this:
Dim MyWorkForm as Form
Set MyWorkForm = Form1
Msgbox MyWorkForm.sv_str_1
This will display the string value for Form1.
In VB.NET, Msgbox MyWorkForm.sv_str_1 will generate an error when
compiling - it says sv_str_1 is not a member of System.Windows.Forms.Form.
This Msgbox Form1.sv_str_1 works in .NET because I did not assign Form1 to a
variable.
This is the same for accessing controls on a VB.NET form. For example, I can
do this in VB6:
Dim MyWorkForm as Form
Set MyWorkForm = Form1
Msgbox MyWorkForm.TextAdd.Text
This will display the value for textbox "TextAdd"
But same does not work in VB.NET. Same error. It says that TextAdd is not a
member of System.Windows.Forms.Form.
Is there a way around this?
TIA
Young