473,785 Members | 2,990 Online
Bytes | Software Development & Data Engineering Community
+ 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 1906
You can add a public value into that form.
then:

obj.ShowDialog
sFile=obj.value name
"carl" <ca**@discussio ns.microsoft.co m> wrote in message
news:20******** *************** ***********@mic rosoft.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.value name
"carl" <ca**@discussio ns.microsoft.co m> wrote in message
news:20******** *************** ***********@mic rosoft.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.SomeFunctio nInMyFormClass

....

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)
InitializeCompo nent()
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
2425
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
2620
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 of that software. That subject seems not to be addressed, at least not directly, in the C FAQ where FAQ 5.2 seems most relevant. References: * C FAQ 5.2 Null pointers (Including conditions where "casting" of null pointer...
16
2000
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 see how the return value comes to play here. Ex
15
6733
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 i = 0,j; j = sample(0);
23
3615
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
1808
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 *********************************************************** function RollDie As Integer Dim Roll As Integer Randomize Roll = Int(rnd * 6) + 1
12
3799
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. 1. The Deserialization goes like: #Region " Load "
7
1808
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 the return type of the function depends on the type of the objects the Input array holds. I can have the return type as Object, but it has problems like late binding and more importantly the client has to always Cast it. For example. class...
2
1923
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 The question may be silly or even meaning less but please............
7
10326
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 IsLvItemCheckedDelegate(ByVal ClientID As Integer) As Boolean Private Function IsLvItemChecked(ByVal ClientID As Integer) As Boolean If lvServers.InvokeRequired = True Then lvServers.Invoke(New IsLvItemCheckedDelegate(AddressOf IsLvItemChecked),...
0
9645
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10327
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8973
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5381
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4053
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 we have to send another system
2
3647
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2879
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.