473,322 Members | 1,566 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

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 1872
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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.