473,471 Members | 4,095 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to pass a variable by reference to a Form

29 New Member
Hi. I make an instance of a form 'B' from Form 'A'. But I need to pass two variables by reference.
I do what you can see below:

Expand|Select|Wrap|Line Numbers
  1. FORM 'B'
  2. Private Val1 As Uintenger
  3. Private Val2 As Boolean
  4. Public Sub New(ByRef _Val1 As Uinteger, ByRef _Val2 As Boolean)
  5. InitializeComponent()
  6.   Val1 = _Val1
  7.   Val2 = _Val2
  8. End Sub
  9.  
  10. Private Sub Proceso()
  11.   Val1 = 333
  12.   Val2 = True
  13.   Me.Close
  14. End Sub
  15.  
  16. FORM 'A'
  17. Dim FormB As New 'B' (Val1, Val2)
  18. FormB.ShowDialog()
  19.  
The problem is that Val1 and Val2 keep their own values before calling Form 'B'

I made an example passing an ArrayList and this modify its value when return, but it seems to be that primitives types (boolean, integer, string, etc) does not work by reference in this context.

Other thing I tried is to pass this variables as Object type, but neither works.

Thanks.
Jun 5 '13 #1
1 1310
Killer42
8,435 Recognized Expert Expert
I haven't had much to do with creating instances of forms like this. But a thought occurs... have you tried using global (sorry, I suppose I mean "Public") variables, rather than passing them? This might be ugly, but if you can't get ByRef to work, at least it might provide a workaround.
Jul 9 '13 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Randell D. | last post by:
Folks, I've asked this before but never got any response but its important and I thought I'd pitch it again (hopefully a bit clearer)... One can pass data from one function to another either...
14
by: dumboo | last post by:
hi there i m little bit confused over the following problem, i have understood wt the following code is doing...but not able to get the actual techinical stuff.....i have had a lot of hot debate...
110
by: Mr A | last post by:
Hi! I've been thinking about passing parameteras using references instead of pointers in order to emphasize that the parameter must be an object. Exemple: void func(Objec& object); //object...
5
by: GB | last post by:
Hello: In my MS Access project I have two objects - my form and my report. I need to pass variable value from Command_click procedure of my form to Report_open procedure of my report. How can I...
5
by: David++ | last post by:
Hi folks, I would be interested to hear peoples views on whether or not 'pass by reference' is allowed when using a Web Service method. The thing that troubles me about pass-by-reference into...
10
by: Robert Dailey | last post by:
Hi, I noticed in Python all function parameters seem to be passed by reference. This means that when I modify the value of a variable of a function, the value of the variable externally from the...
6
by: lisp9000 | last post by:
I've read that C allows two ways to pass information between functions: o Pass by Value o Pass by Reference I was talking to some C programmers and they told me there is no such thing as...
11
by: venkatagmail | last post by:
I have problem understanding pass by value and pass by reference and want to how how they are or appear in the memory: I had to get my basics right again. I create an array and try all possible...
12
by: Bryan Parkoff | last post by:
I write my large project in C++ source code. My C++ source code contains approximate four thousand small functions. Most of them are inline. I define variables and functions in the global scope....
2
by: peachdot | last post by:
hi, The MainForm will have 2 buttons: 1.) Button A : User click button A, hide Mainform then go to form1. User enter data in the textbox.Click finish button,form1 close then go back to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.