473,472 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

VB - Return Val from Frm as Function

How can you return the value of a (sub)form to another form as a function?
My sub form is a similar to a "file list" form.
On my main form, it runs the subs and if can't find a file it calls the sub
form for user input.
My code will be something like:

Sub MainForm
'do stuff
If FileExist(sFile) = false Then
sFile= ??'result of sub form
End If
'do more stuff with sFile
End Sub
Aug 17 '05 #1
4 1876
You can add a public value into that form.
then:

obj.ShowDialog
sFile=obj.valuename
"carl" <ca**@discussions.microsoft.com> wrote in message
news:20**********************************@microsof t.com...
How can you return the value of a (sub)form to another form as a function?
My sub form is a similar to a "file list" form.
On my main form, it runs the subs and if can't find a file it calls the
sub
form for user input.
My code will be something like:

Sub MainForm
'do stuff
If FileExist(sFile) = false Then
sFile= ??'result of sub form
End If
'do more stuff with sFile
End Sub

Aug 17 '05 #2
Allen
I get an error, Object doesn't support the method or property. I'm using VB.

"Allen St.Clair" wrote:
You can add a public value into that form.
then:

obj.ShowDialog
sFile=obj.valuename
"carl" <ca**@discussions.microsoft.com> wrote in message
news:20**********************************@microsof t.com...
How can you return the value of a (sub)form to another form as a function?
My sub form is a similar to a "file list" form.
On my main form, it runs the subs and if can't find a file it calls the
sub
form for user input.
My code will be something like:

Sub MainForm
'do stuff
If FileExist(sFile) = false Then
sFile= ??'result of sub form
End If
'do more stuff with sFile
End Sub


Aug 17 '05 #3
How are you calling it? If you add a function or sub or property to
the form class, you can access it from an instance of the class.

Dim frm As New MyFormClass

sFile = frm.SomeFunctionInMyFormClass

....

Aug 17 '05 #4
If the "sub form" is a modal dialog, just pass a ref parameter via the
constructor.
e.g.,
Public Sub New(ByRef sFile As String)
InitializeComponent()
Me.ShowDialog()
sFile = m_sFile 'set from elsewhere on form before closing
End Sub
--
David Anton
www.tangiblesoftwaresolutions.com
Home of:
Clear VB: Cleans up outdated VB.NET code
Instant C#: Converts from VB.NET to C#
Instant VB: Converts from C# to VB.NET
Instant J#: Converts from VB.NET to J#
"carl" wrote:
How can you return the value of a (sub)form to another form as a function?
My sub form is a similar to a "file list" form.
On my main form, it runs the subs and if can't find a file it calls the sub
form for user input.
My code will be something like:

Sub MainForm
'do stuff
If FileExist(sFile) = false Then
sFile= ??'result of sub form
End If
'do more stuff with sFile
End Sub

Aug 17 '05 #5

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

Similar topics

17
by: strout | last post by:
function F(e) { return function(){P(e)} } Can anybody tell me what the code is doing? If return another function all in a function I would do function F(e)
10
by: LaEisem | last post by:
On-the-job, I have "inherited" a lot of old C language software. A question or two about when "casting" of null pointer constants is needed has occurred during behind-the-scenes cleanup of some...
16
by: G Patel | last post by:
Hi, If I want to call functions that don't return int without declaring them, will there be any harm? I only want to assign the function(return value) to the type that it returns, so I don't...
15
by: Greenhorn | last post by:
Hi, when a function doesn't specify a return type ,value what value is returned. In the below programme, the function sample()is returning the value passed to 'k'. sample(int); main() { int...
23
by: Nascimento | last post by:
Hello, How to I do to return a string as a result of a function. I wrote the following function: char prt_tralha(int num) { int i; char tralha;
3
by: Thomas Scheiderich | last post by:
I am curious as to why ASP.NET returns values a different way from VB or VB.net (or can you use both). In my one book I have it returning using a return statement ...
12
by: Michael Maes | last post by:
Hello, I have a BaseClass and many Classes which all inherit (directly) from the BaseClass. One of the functions in the BaseClass is to (de)serialize the (inherited) Class to/from disk. ...
7
by: nafri | last post by:
hello all, I want to create a function that returns the first element of the Array that is input to it. However, the Input Array can be an Array of points, double, or anyother type, which means...
2
by: mosesdinakaran | last post by:
Hi everybody, Today I faced a problem where I am very confused and I could not solve it and I am posting here.... My question is Is is possible to return a value to a particular function ...
7
by: Terry Olsen | last post by:
How do I get this to work? It always returns False, even though I can see "This is True!" in the debug window. Do I have to invoke functions differently than subs? Private Delegate Function...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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,...
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...
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...
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: 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.