473,796 Members | 2,505 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

carry values across forms

Hi,

I have a series of forms that collect information from a user. When I write
out my information to a text file after the last file, the values of the
previous forms seem to be blank. I would like to retain the values of
names.textbox1. text and names.textbox2. text for the output file.

Any help greatly appreciated.


Private Sub Button2_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button2.Click

TextBox1.Focus( )

Dim names As New Names

Dim sw As New IO.StreamWriter (filer, True) ' True means append

Dim strName As String = names.TextBox1. Text

Dim strValue As String = names.TextBox2. Text

Dim today As Date = Now()

Dim strdate As String = today.ToString( "d")

Dim golfScore As String = TextBox1.Text

sw.WriteLine(St ring.Format("{0 },{1},{2},{3}", strName, strValue, strdate,
golfScore))

sw.Flush()

sw.Close()

names.Show()

Me.Hide()

End Sub
Nov 21 '05 #1
7 1439
Gordon,

How do you want to have values in this properties.

Dim names As New Names
Dim sw As New IO.StreamWriter (filer, True) ' True means append
Dim strName As String = names.TextBox1. Text
Dim strValue As String = names.TextBox2. Text

Or you should really do something against all rules, than the textbox1 and
textbox2 in the form/panel/groupbox Names are empty.

Cor
Nov 21 '05 #2
Thanks Cor

But I dont quite understand your meaning.

Names is the form that contains textboxe1 and textbox2. There is a button
on that form that allows me to move to another form - scores.
I can then input some values into textbox1 in scores and then I want to
write these to the text file.

so I want the values in the names.textbox1. text and names.textbox2. text to
be available for output as a result of clicking on a button in scores.

Is that what you mean?

Doug
"Cor Ligthert" <no************ @planet.nl> wrote in message
news:em******** ******@TK2MSFTN GP12.phx.gbl...
Gordon,

How do you want to have values in this properties.

Dim names As New Names
Dim sw As New IO.StreamWriter (filer, True) ' True means append
Dim strName As String = names.TextBox1. Text
Dim strValue As String = names.TextBox2. Text

Or you should really do something against all rules, than the textbox1 and
textbox2 in the form/panel/groupbox Names are empty.

Cor

Nov 21 '05 #3
Gordon

Have a look at the code I showed you as you had made it..
Dim names As New Names I assume that Names is a Form. You create a completly New form what is
normally completly empty.
Dim strName As String = names.TextBox1. Text
Dim strValue As String = names.TextBox2. Text


You transfering than the values from empty textboxes in two string values.
That has not so much sense.

Why do you create that new form anyhow, I assume that that button is on the
form on which are as well those two textboxes..

Cor
Nov 21 '05 #4
Gordon,

As a side step

dim a as New A

is working in VBNet 2003

I don't think that anywhere is guaranteed that this will work in whatever
future version as well.

For VBNet it does at least in one thing not fulfil a programming rule.
It has to be understandable for somebody else who is well known with the
program language.

I hope this gives an idea.

Cor
Nov 21 '05 #5
I understand what you are saying in relation to transferrring code from one
version to another. My programming language is SAS and it is important to
code well. I am learning Vb.net and am trying to understand the language by
working through some small examples.
However, for my example, I am unable to get the code to work.

Let me put my need antother way.

I have two forms - i want to collect data from the first form and use it in
the second form.

My first form is called names and has textbox1 and textbox2 and a button to
take me to the second form called scores. The second form has more
information that is gathered and once a button is clicked it is appended to
the information from the textbox1 and textbox2 and then written out to a
text file.

If my first form is as I say - textbox1 and textbox2, how can i reference
these values elsewhere in my application?

Thanks

sorry If i have missed the point - but as I say i am new to vb.net.


"Cor Ligthert" <no************ @planet.nl> wrote in message
news:OU******** ******@TK2MSFTN GP15.phx.gbl...
Gordon,

As a side step

dim a as New A

is working in VBNet 2003

I don't think that anywhere is guaranteed that this will work in whatever
future version as well.

For VBNet it does at least in one thing not fulfil a programming rule.
It has to be understandable for somebody else who is well known with the
program language.

I hope this gives an idea.

Cor

Nov 21 '05 #6
Gordon,

In VBNet is this one of the most difficult points. Even more because a lot
of people try to use the VB6 methods.

To do what you ask i reply what you told.
You have a main form that has the major textboxes
You have second form that you use to get the scores in a textbox and write
those to a file together with the two values from your mainform..

Although that I can tell you how to get the names from those textboxes on
form2, is that not a good method.

Better is to pass those values to your second form.
The best thing is to do that in the constructor, however that is as well a
little bit complicated when you are new.
Therefore I tell it you in the most easiest way.

You create on your second form two fields
Friend TheName as String ('str in advance is not done)
Friend TheValue as String (and not Name and Value because that are both
often used names in classes)

In your first form you set now where you open that second form

frm2 as new Form2
frm2.TheName = textbox1.text
frm2.TheValue = textbox2.text
frm2.showdialog 'now the process it stays at form2 because of that
showdialog and the process on form1 stops.
frm2.dispose 'this is one of the exceptions where dispose is adviced.

Now you can do what you want in Form2, except that you do not use that new
form Names however TheName and TheValue direct.

I hope this helps,

Cor



I assume that you did it on your mainform
"gordon" <go**********@o ptusnet.com.au> schreef in bericht
news:42******** *************** @news.optusnet. com.au...
I understand what you are saying in relation to transferrring code from one
version to another. My programming language is SAS and it is important to
code well. I am learning Vb.net and am trying to understand the language
by working through some small examples.
However, for my example, I am unable to get the code to work.

Let me put my need antother way.

I have two forms - i want to collect data from the first form and use it
in the second form.

My first form is called names and has textbox1 and textbox2 and a button
to take me to the second form called scores. The second form has more
information that is gathered and once a button is clicked it is appended
to the information from the textbox1 and textbox2 and then written out to
a text file.

If my first form is as I say - textbox1 and textbox2, how can i reference
these values elsewhere in my application?

Thanks

sorry If i have missed the point - but as I say i am new to vb.net.


"Cor Ligthert" <no************ @planet.nl> wrote in message
news:OU******** ******@TK2MSFTN GP15.phx.gbl...
Gordon,

As a side step

dim a as New A

is working in VBNet 2003

I don't think that anywhere is guaranteed that this will work in whatever
future version as well.

For VBNet it does at least in one thing not fulfil a programming rule.
It has to be understandable for somebody else who is well known with the
program language.

I hope this gives an idea.

Cor


Nov 21 '05 #7

Cor,

Thanks again. You help so many people on this discussion group. I
understand that you are a professional vb.net programmer and it must make
you cringe sometimes with the questions on this group (such as mine). Your
kind assistance is appreciated, as is your willingness to follow-up with
additional information.

Thanks again - my simple forms are now working - but I promise I will read
up on the constructor!!

Doug
"Cor Ligthert" <no************ @planet.nl> wrote in message
news:ep******** ******@tk2msftn gp13.phx.gbl...
Gordon,

In VBNet is this one of the most difficult points. Even more because a lot
of people try to use the VB6 methods.

To do what you ask i reply what you told.
You have a main form that has the major textboxes
You have second form that you use to get the scores in a textbox and write
those to a file together with the two values from your mainform..

Although that I can tell you how to get the names from those textboxes on
form2, is that not a good method.

Better is to pass those values to your second form.
The best thing is to do that in the constructor, however that is as well a
little bit complicated when you are new.
Therefore I tell it you in the most easiest way.

You create on your second form two fields
Friend TheName as String ('str in advance is not done)
Friend TheValue as String (and not Name and Value because that are both
often used names in classes)

In your first form you set now where you open that second form

frm2 as new Form2
frm2.TheName = textbox1.text
frm2.TheValue = textbox2.text
frm2.showdialog 'now the process it stays at form2 because of that
showdialog and the process on form1 stops.
frm2.dispose 'this is one of the exceptions where dispose is adviced.

Now you can do what you want in Form2, except that you do not use that new
form Names however TheName and TheValue direct.

I hope this helps,

Cor



I assume that you did it on your mainform
"gordon" <go**********@o ptusnet.com.au> schreef in bericht
news:42******** *************** @news.optusnet. com.au...
I understand what you are saying in relation to transferrring code from
one version to another. My programming language is SAS and it is
important to code well. I am learning Vb.net and am trying to understand
the language by working through some small examples.
However, for my example, I am unable to get the code to work.

Let me put my need antother way.

I have two forms - i want to collect data from the first form and use it
in the second form.

My first form is called names and has textbox1 and textbox2 and a button
to take me to the second form called scores. The second form has more
information that is gathered and once a button is clicked it is appended
to the information from the textbox1 and textbox2 and then written out to
a text file.

If my first form is as I say - textbox1 and textbox2, how can i reference
these values elsewhere in my application?

Thanks

sorry If i have missed the point - but as I say i am new to vb.net.


"Cor Ligthert" <no************ @planet.nl> wrote in message
news:OU******** ******@TK2MSFTN GP15.phx.gbl...
Gordon,

As a side step

dim a as New A

is working in VBNet 2003

I don't think that anywhere is guaranteed that this will work in
whatever future version as well.

For VBNet it does at least in one thing not fulfil a programming rule.
It has to be understandable for somebody else who is well known with the
program language.

I hope this gives an idea.

Cor



Nov 21 '05 #8

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

Similar topics

6
8689
by: Dave | last post by:
I came across an article in SQL Mag about Crosstab Queries. It works great in Query Analyzer, but I'm stuck on how to use it in an Access ADP. I need to use it as a Recordsource in a form and report. Can someone tell me how to use it, and please try to be as descriptive as possible. I'm new to Stored Procedures. Thanks *****************************************
1
1768
by: David | last post by:
Hi, I have an ASP page with a form and the following code: ..... type=Radio Checked name=selectserial value=" & RS("PSL_F_Serial")..... Tis will carry over the value of RS("PSL_F_Serial"), but I also have another value which needs to be carried (2 values per radio button), RS("PSL_L_Serial").
5
15711
by: Ed Havelaar | last post by:
I have a cool function that I want to use as a default value for a column in my table. But I can't because apparently Access doesn't allow user defined functions in expressions for default values. It's very annoying. Is there any way around it? What I need is something like AutoNumber, *except* I want the values to be unique across six different tables. Any ideas? Unknown function <name> in validation expression or default value...
2
8985
by: Almir | last post by:
I have a simple problem, i just can get a grasp on it. I designed a database for inventory of computer equipment. Now i created forms for each table. Each piece of equipment is going to come in an order. ORDERS --> ORDER CONTENTS --> DEVICES --> CPUS --> PRINTERS --> NETWORK HARDWARE You get the picture. I want to make the updating easy. I start from ORDERS table enter all the common information, then ORDER CONTENTS table and get all...
2
3005
by: Paul Malcomson | last post by:
Hi. I'm having terrible trouble with a form that displays several parent/child relationships at one time. It is a sales force hierarchy - Sales force, district, territory, sales rep are the tables linked in parent/child relationships. I'm using a form to choose the main-parent and then several subforms in datasheet view.
16
4066
by: archilleswaterland | last post by:
Hi, I am using a compiler that does not support long int (32 bits) so I am using 2 int's to do the work my problem int a; int b; int c;
5
3950
by: campbellbrian2001 | last post by:
I'm trying to get the "Carry data over to new record" code to work from Allen Browne's site: http://allenbrowne.com/ser-24.html I follwed the instruction explicitly and somethings not working... any clues? Thanks all!! Brian
3
2181
chunk1978
by: chunk1978 | last post by:
hi there... i'm trying to make one text field contain the value of another... i'm assuming there's a really simple solution... here's a code i quickly wrote to further explain my issue: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />...
3
1378
by: RoRNoob | last post by:
I'd like the bar.html file to take the values contained in hidden fields and stuff them into the form fields found on mymessagebox.html. I can get it working no problem if it is all on the same page, but I'm having trouble getting it to work across pages via the index.html frames. Any help is appreciated. code: ----- application.js -----
0
9680
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
9528
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
10230
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10012
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9052
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...
1
7548
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6788
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5442
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...
2
3731
muto222
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.