| | |
byref in vb.net
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Apr 2008
Posts: 26
Reputation:
Solved Threads: 0
hey guys.
here is a scenario:
i have a form named frm1 and a variable in it
and another form called frm2 that needs to be able to make a local copy of "x" from frm1 and any changes made to "x" on frm2 needs to be changed on frm1.
so in frm2 i do
and from frm1 i create frm2 as follows:
and now any changes made to 'number' inside frm2 should change 'x' in frm1 shouldnt it? this does work if you're using a textbox object since the project im working in does exactly that. but when i try and do it for a variable like single/string/integer it doesnt work. it changes the local variable on frm2 but not the variable on frm1.
here is a scenario:
i have a form named frm1 and a variable in it
VB.NET Syntax (Toggle Plain Text)
private x as integer = 0
and another form called frm2 that needs to be able to make a local copy of "x" from frm1 and any changes made to "x" on frm2 needs to be changed on frm1.
so in frm2 i do
VB.NET Syntax (Toggle Plain Text)
private number as integer Public Sub New(ByRef x as integer) number = x end sub
and from frm1 i create frm2 as follows:
VB.NET Syntax (Toggle Plain Text)
public sub createfrm() dim frm as new frm2(x) frm.showdialogue() end sub
and now any changes made to 'number' inside frm2 should change 'x' in frm1 shouldnt it? this does work if you're using a textbox object since the project im working in does exactly that. but when i try and do it for a variable like single/string/integer it doesnt work. it changes the local variable on frm2 but not the variable on frm1.
Hi,
I think Single, Integer, Double Char all are ValueType, So It is not working. Also you can override the ShowDialog() and pass your value
For Example In Form2
To Show Form2 In Form1
Declare
I am using MessageBox to Show before and After calling the ShowDialog
I think Single, Integer, Double Char all are ValueType, So It is not working. Also you can override the ShowDialog() and pass your value
For Example In Form2
VB.NET Syntax (Toggle Plain Text)
Public Shadows Sub ShowDialog(ByRef x As Integer) MyBase.ShowDialog() x = 566 End Sub
To Show Form2 In Form1
Declare
Private Number as Integer VB.NET Syntax (Toggle Plain Text)
Dim NewForm As New Form2 MessageBox.Show(Number) NewForm.ShowDialog(Number) MessageBox.Show(Number)
KSG
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
So, Please do something before post your thread.
* PM Asking will be ignored *
![]() |
Similar Threads
- Tutorial: Understanding ASP classes (ASP)
- sending sms using vb.net (VB.NET)
- StreamReader and Position (In VB) (VB.NET)
- Calling COM method (CallByName?) with reference parameters (VB.NET)
- convert CardFrameSize=pResponseData[1]&0x0f; to VB .NET (VB.NET)
- Runtime error:453 cannot find dllentrypoint (Visual Basic 4 / 5 / 6)
- Validation difficulties *sigh* (ASP.NET)
- moving a form with no border (VB.NET)
Other Threads in the VB.NET Forum
- Previous Thread: Error in line of code
- Next Thread: Syntax error on update database code
| Thread Tools | Search this Thread |
Tag cloud for VB.NET
.net .net2008 2005 2008 access account application arithmetic array arrays basic bing button buttons c# center check checkbox code convert crystalreport data database datagrid datagridview date dissertation dissertations dropdownlist excel fade file-dialog filter ftp generatetags google gridview hardcopy images inline input insert intel internet listview mobile monitor ms net networking objects output panel passingparameters picturebox picturebox1 port position print printing problem project read remove save searchbox searchvb.net select serial shutdown soap sorting survey table tcp temperature text textbox timer timespan toolbox trim update user validation vb vb.net vb.netformclosing()eventpictureboxmessagebox vb2008 vbnet view visual visualbasic visualbasic.net visualstudio2008 web webbrowser winforms wpf year






