473,320 Members | 1,600 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,320 software developers and data experts.

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(ByVal sender As System.Object, ByVal e As
System.EventArgs) 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(String.Format("{0},{1},{2},{3}", strName, strValue, strdate,
golfScore))

sw.Flush()

sw.Close()

names.Show()

Me.Hide()

End Sub
Nov 21 '05 #1
7 1422
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**************@TK2MSFTNGP12.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**************@TK2MSFTNGP15.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**********@optusnet.com.au> schreef in bericht
news:42***********************@news.optusnet.com.a u...
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**************@TK2MSFTNGP15.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**************@tk2msftngp13.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**********@optusnet.com.au> schreef in bericht
news:42***********************@news.optusnet.com.a u...
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**************@TK2MSFTNGP15.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
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...
1
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"),...
5
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....
2
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...
2
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...
16
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
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......
3
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: ...
3
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...
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: 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: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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: 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.