473,322 Members | 1,736 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.

Return a string

Hi, all! How can a show up a form then get a return string from it when
it close? I mean like inputbox! Thanks in advance

Regards,
Stanley

Nov 21 '05 #1
8 1171
Hi Stanley,

Form 1. Add a textBox & a button
Form 2 Add a TextBox & a Button

Add this code to form 1 behind a button

Dim frm As New Form2
frm.ShowDialog()
Me.TextBox1.Text = frm.TextBox1.Text
frm.Dispose()

Behind the button on form2:

Me.Close()

------------------------------

Whatever you type in the textbox of form 2 will appear in the textbox of
form1

I hope this helps

Crouchie1998
BA (HONS) MCP MCSE
Nov 21 '05 #2
Hi,

Stanley wrote:
Hi, all! How can a show up a form then get a return string from it when
it close? I mean like inputbox! Thanks in advance


create a simple class that wraps up your query-form. I.e.:

public class frm_UserQuery
'your form-stuff goes here and should include a textbox (txtUserInput),
'a label (lblInstructions) and two buttons (OK with DialogResult.OK,
'Cancel with i.e. DialogResult.Cancel). Both buttons will close the form
end class

public class CUserQuery

public shared sub getUserInput(byval strQueryText as string) as string
dim frmQ as new new frm_UserQuery
dim strUserInput as string

frmQ.lblInstructions.text=strQueryText

frmQ.ShowDialog()

if frmQ.DialogResult = DialogResult.OK then
'User clicked the OK-button
strUserInput=txtUserInput.text
else
'User clicked the Cancel-button
strUserInput=string.empty
end if

frmQ.dispose

return strUserInput
end sub

end class

From your main form, call the above with i.e.
dim strUserInput as string = _
CUserQuery.getUserInput("Please enter something smart:")

Cheers,
Olaf
Nov 21 '05 #3
"Stanley" <xs******@gmail.com> wrote in news:1119341248.549537.237610
@o13g2000cwo.googlegroups.com:
Hi, all! How can a show up a form then get a return string from it when
it close? I mean like inputbox! Thanks in advance


http://www.codeproject.com/dotnet/Wo...thWinForms.asp
--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"

Get your ASP.NET in gear with IntraWeb!
http://www.atozed.com/IntraWeb/
Nov 21 '05 #4
"Stanley" <xs******@gmail.com> schrieb:
How can a show up a form then get a return string from it when
it close? I mean like inputbox!


<URL:http://www.google.to/groups?selm=%237sTDoqHFHA.3208%40TK2MSFTNGP10.phx. gbl>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #5
"Stanley" <xs******@gmail.com> schrieb:
How can a show up a form then get a return string from it when
it close? I mean like inputbox!


<URL:http://www.google.to/groups?selm=%237sTDoqHFHA.3208%40TK2MSFTNGP10.phx. gbl>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #6
Thanks all for precious information! I really appreciate them! Thanks
again!

Nov 21 '05 #7
Thanks all for precious information! I really appreciate them! Thanks
again!

Nov 21 '05 #8
All:

A question rather than an answer.

It has been recommended to me that I use a specific style for getting
information from pop-up dialogs/forms and would like some opinions on
it.
Problem:
We have a pop-up form that is to be used for inputting a handful (say
5) of values.
Recommended Solution:

Create a class to hold the values to be populated

e.g.

class PersonInfo
Public Forename as string
Public Surname as string
Public Age as integer
Public Email as EmailAddress // Custom class, declared
elsewhere
Public PhoneNbr as PhoneNumber // ditto
end class

Pass and instance of this class into the form as part of the ctor, and
when the user presses OK on the form, it (the form code) will update
the instance with the values from the screen.

e.g.

dim perInfo as New PersonInfo
dim frm as new PersonInfo(perInfo)

if (frm.ShowDialog(me) = DialogResult.OK) then

< do various things with the values in perInfo

end if

Is this overkill?
Does it gain anything (at all) over jut declaring properties on the
form?
It is more useful if we are passing values into the pop-up?
Thanks in advance,

Alan.

Nov 21 '05 #9

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

Similar topics

3
by: Phil Powell | last post by:
My first time working with a PHP class, and after 6 hours of working out the kinks I am unable to return a value from the class, so now I appeal to the general audience what on earth did I do wrong...
12
by: Jose Fernandez | last post by:
Hello. I'm building a web service and I get this error. NEWS.News.CoverNews(string)': not all code paths return a value This is the WebMethod public SqlDataReader CoverNews(string Sport)...
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...
16
by: Dany | last post by:
Our web service was working fine until we installed .net Framework 1.1 service pack 1. Uninstalling SP1 is not an option because our largest customer says service packs marked as "critical" by...
9
by: MSDNAndi | last post by:
Hi, I have a set of simple webservices calls that worked fine using .NET Framework 1.0. I am calling a Java/Apache based webservices, the calling side is not able to supply a proper WSDL. ...
18
by: Pedro Pinto | last post by:
Hi there once more........ Instead of showing all the code my problem is simple. I've tried to create this function: char temp(char *string){ alterString(string); return string;
2
by: utab | last post by:
Dear all, I tried sth easy(actually this was an exercise) but I tried to use the standard lib. heavily for this problem(as far as I can). There was one point I could not figure out. The problem...
6
KoreyAusTex
by: KoreyAusTex | last post by:
If anyone can help me figure out the what the missing return statements are, I think it might be the fact that I need to add a return false in the getValue()? import java.util.*; public class...
14
by: =?Utf-8?B?QmVu?= | last post by:
Hi all, I'm trying to understand the concept of returning functions from the enclosing functions. This idea is new to me and I don't understand when and why I would need to use it. Can someone...
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...
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: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
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: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.