473,473 Members | 2,185 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

passing class level variable byref

Cc
hi,
how do I pass byref a variable at class level? , something like how dataset
work,event if declare at class level but it always pass as ref.
Nov 20 '05 #1
5 6208
Hi Cc,

I'm afraid that I don't understand your query. Could you give a few more
details, please?

Regards,
Fergus
Nov 20 '05 #2
Cc
for example
I have form call form1.vb and class call class1.vb . on class1.vb you have
function A and B . if for example u need to pass a variable byref from
form1 to class1 what we usually do is declare function with parameter
passing byref. this is allright if for 1 or 2 function, but if all function
in class1 required the variable tobe pass as ref this could be tedious when
everytime calling the function in class1. that why i ask is there better
solution in this.


"Fergus Cooney" <fi******@tesco.net> wrote in message
news:uk**************@TK2MSFTNGP12.phx.gbl...
Hi Cc,

I'm afraid that I don't understand your query. Could you give a few more details, please?

Regards,
Fergus

Nov 20 '05 #3
"Cc" <ko*****@singnet.com.sg> schrieb
for example
I have form call form1.vb and class call class1.vb . on class1.vb
you have function A and B . if for example u need to pass a
variable byref from form1 to class1 what we usually do is declare
function with parameter passing byref. this is allright if for 1 or 2
function, but if all function in class1 required the variable tobe
pass as ref this could be tedious when everytime calling the function
in class1. that why i ask is there better solution in this.


I hope I understood you right. First, you only need to pass the Form "ByRef"
if you want to create a *new* Form in class1. If you don't create a new Form
in Class1, pass the Form ByVal. Second, why don't you write the code in
Form1?
--
Armin

Nov 20 '05 #4
"Cc" <ko*****@singnet.com.sg> schrieb:
I have form call form1.vb and class call class1.vb .
on class1.vb you have function A and B . if for example
u need to pass a variable byref from form1 to class1 what
we usually do is declare function with parameter
passing byref.


Make sure you understand the difference between 'ByVal' and 'ByRef' for
reference types:

\\\
Public Sub Main()
Dim sb As New StringBuilder("BBB")
changeit1(sb)
MsgBox(sb.ToString())
sb = New StringBuilder("BBB")
changeit2(sb)
MsgBox(sb.ToString())
System.Console.ReadLine()
End Sub

Private Sub changeit1(ByVal s As StringBuilder)
s = New StringBuilder()
s.Append("Bla")
End Sub

Private Sub changeit2(ByRef s As StringBuilder)
s = New StringBuilder()
s.Append("Bla")
End Sub
///

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #5
Hi Cc,

|| but if all function in class1 required the variable
|| to be pass as ref this could be tedious when
|| everytime calling the function in class1.

I'm not sure what's tedious about it? Is it too much to type ByRef in your
parameter list ?

However, if the variable that you are passing is an object of any sort, it
is <already> a reference variable and wouldn't need ByRef.

Have I understood your query ?

Regards,
Fergus
Nov 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Andy Read | last post by:
Dear all, I thought I understood passing parameters ByVal and ByRef but I clearly don't! If I define a simple class of: Public Class Person Public Name as String Public Age as Integer End...
2
by: Ryan Malone | last post by:
Passing Dictionary object byref Ive created an ASP class that uses a dictionary object which is filled from a recordset. It passes the object to the propterty of another ASP class byref: ...
39
by: Mike MacSween | last post by:
Just spent a happy 10 mins trying to understand a function I wrote sometime ago. Then remembered that arguments are passed by reference, by default. Does the fact that this slowed me down...
7
by: Rik | last post by:
Hi, I have an Multithreaded application in VB.NET. I inherited a Sub Class and which define an Array variable of string in that Sub Class. Now I want to Carry that Sub Class Array back to...
2
by: Witold Iwaniec via .NET 247 | last post by:
It seems that when you pass an object to a function it is always passed by reference even if it is explicitly declared ByVal. Is it the behavior of VB.Net? Here is sample code from sample Asp.Net...
11
by: John Pass | last post by:
Hi, In the attached example, I do understand that the references are not changed if an array is passed by Val. What I do not understand is the result of line 99 (If one can find this by line...
8
by: Peter | last post by:
I will excute the code below to get MethodName array. These codes are edited under VS2003. Now I want to upgrade it to VS2005,but VS2005 gives me a varning message: The varible "sSourceMethodName"...
2
by: Phoenix | last post by:
Hi Friends , Could anyone please help me to resolve the following issue : I pass an array of structures to a dll written in VC++ 6.0 whih fills it with data . The following works well for VB...
0
by: VaBa | last post by:
Hi, Need some help.. I have a VBA class module in MS ACCESS. In the same MS ACCESS app, I am calling a .NET DLL (which i have exposed as COM-visible) and passing BYREF an instance of the VBA class...
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
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
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.