473,480 Members | 1,669 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Save info from a form to disk?

Hi!

I haven't worked with streams before.

On a form I have:

A. cboValues = A combobox with text values where the user can choose
a value
B. txtText = A textbox where the user can enter text
C. cboDatePicker = A Datetime picker where the user can choose a
date

Now, when he/she chooses the OK-button, I would like to save the data
to disk into a text-file like:

Dim MyDir as string,MyFile as string,MyFileExt as string

'This directory already exists as it was created during the OnLoad
of main form.
MyDir = "C:\APlace\"

'Now the file....
MyFile = cboValues & "_" & cboDatePicker
MyFileExt = ".txt"
MyPath = Trim(MyDir & MyFile & MyFileExt)

I understand that I should use a stream. Anybody that can show me how I
do this?

Didn't understand so much from the helpfile.

Me.Name

Nov 21 '05 #1
10 1673
Imports System.io
Imports System.Convert

Dim myStream As FileStream

Dim i As Integer
Dim letter As Char

myStream = New FileStream(MyPath, FileMode.OpenOrCreate)
For i = 1 To TextBox1.Text.Length
letter = Mid(TextBox1.Text, i, 1)
arrText = ToByte(letter)

myStream.WriteByte(arrText)
Next

You'll have probs with your path. When you convert your datepicker to string
you'll have something like "_12/9/05". This is illegal as a file path (I
think).

HTH, Phil
<gs***@hotmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
Hi!

I haven't worked with streams before.

On a form I have:

A. cboValues = A combobox with text values where the user can choose
a value
B. txtText = A textbox where the user can enter text
C. cboDatePicker = A Datetime picker where the user can choose a
date

Now, when he/she chooses the OK-button, I would like to save the data
to disk into a text-file like:

Dim MyDir as string,MyFile as string,MyFileExt as string

'This directory already exists as it was created during the OnLoad
of main form.
MyDir = "C:\APlace\"

'Now the file....
MyFile = cboValues & "_" & cboDatePicker
MyFileExt = ".txt"
MyPath = Trim(MyDir & MyFile & MyFileExt)

I understand that I should use a stream. Anybody that can show me how I
do this?

Didn't understand so much from the helpfile.

Me.Name

Nov 21 '05 #2
Imports System.io
Imports System.Convert

Dim myStream As FileStream

Dim i As Integer
Dim letter As Char

myStream = New FileStream(MyPath, FileMode.OpenOrCreate)
For i = 1 To TextBox1.Text.Length
letter = Mid(TextBox1.Text, i, 1)
arrText = ToByte(letter)

myStream.WriteByte(arrText)
Next

You'll have probs with your path. When you convert your datepicker to string
you'll have something like "_12/9/05". This is illegal as a file path (I
think).

HTH, Phil
<gs***@hotmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
Hi!

I haven't worked with streams before.

On a form I have:

A. cboValues = A combobox with text values where the user can choose
a value
B. txtText = A textbox where the user can enter text
C. cboDatePicker = A Datetime picker where the user can choose a
date

Now, when he/she chooses the OK-button, I would like to save the data
to disk into a text-file like:

Dim MyDir as string,MyFile as string,MyFileExt as string

'This directory already exists as it was created during the OnLoad
of main form.
MyDir = "C:\APlace\"

'Now the file....
MyFile = cboValues & "_" & cboDatePicker
MyFileExt = ".txt"
MyPath = Trim(MyDir & MyFile & MyFileExt)

I understand that I should use a stream. Anybody that can show me how I
do this?

Didn't understand so much from the helpfile.

Me.Name

Nov 21 '05 #3
Thanks!

I know.

The full path to file contains of some text I didn't bother to write.
The full filename will be something like:

TodayFile_12/9/05.txt

Nov 21 '05 #4
Thanks!

I know.

The full path to file contains of some text I didn't bother to write.
The full filename will be something like:

TodayFile_12/9/05.txt

Nov 21 '05 #5
Hi again!

What declarations for:

arrText and ToByte?

Me.Name

Nov 21 '05 #6
Hi again!

What declarations for:

arrText and ToByte?

Me.Name

Nov 21 '05 #7
arrText probably should be bytText but anyhow, it's Dim arrText as Byte

ToByte is actually a method of system.convert.

Good luck. Phil

<gs***@hotmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
Hi again!

What declarations for:

arrText and ToByte?

Me.Name

Nov 21 '05 #8
arrText probably should be bytText but anyhow, it's Dim arrText as Byte

ToByte is actually a method of system.convert.

Good luck. Phil

<gs***@hotmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
Hi again!

What declarations for:

arrText and ToByte?

Me.Name

Nov 21 '05 #9
I came to think of the following:

Why save data to disk? Why not write it directly from Form2 to Form1?

I have:

A. cboValues = A combobox with text values where the user can choose
a value
B. txtText = A textbox where the user can enter text
C. cboDatePicker = A Datetime picker where the user can choose a
date

Now suppose I remove the last option and remains with only A and B.

Should I not be able to write data to the ListView on Form1 as user
click's the OK-button? And from there I could save the ListView to disk
into a .txt-file? Shouldn't this be easier?

The ListView contains of two columns:

Column1 holds the same values as the cboValues on the Form2.
Column2 holds the text from txtText on Form2

How can I pass data from the Form2 into the ListView of Form1?

Me.Name

Nov 21 '05 #10
I came to think of the following:

Why save data to disk? Why not write it directly from Form2 to Form1?

I have:

A. cboValues = A combobox with text values where the user can choose
a value
B. txtText = A textbox where the user can enter text
C. cboDatePicker = A Datetime picker where the user can choose a
date

Now suppose I remove the last option and remains with only A and B.

Should I not be able to write data to the ListView on Form1 as user
click's the OK-button? And from there I could save the ListView to disk
into a .txt-file? Shouldn't this be easier?

The ListView contains of two columns:

Column1 holds the same values as the cboValues on the Form2.
Column2 holds the text from txtText on Form2

How can I pass data from the Form2 into the ListView of Form1?

Me.Name

Nov 21 '05 #11

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

Similar topics

5
5455
by: grz02 | last post by:
A question on html-forms: We have an application where users will get a CD with, among other things, some html-forms for them to fill in. When they click the submit-button, the data is...
0
1724
by: beau | last post by:
Please help me ! Anybody can help me with a code to embed an ms word file into an access table ? I have ms word templates with bookmarks in my hard disk. So far I can open the template...
0
1979
by: beau | last post by:
Re. Embed or save ms word into OLE field Please help me ! Anybody can help me with a code to embed an ms word file into an access table ? I have ms word templates with bookmarks in my hard...
3
3273
by: N J | last post by:
Hi, I have 2 forms open at the same time, Form 1 adds information to a field on a record that Form 2 has open. It used to show the new information on Form 2 straight away in a text box but now...
2
2348
by: Tim T | last post by:
Hi, Could someone please point to to a tutorial / code for dynamically resizing images on upload, THEN saving to disk on the webserver. I need users to be able to upload images to my server, but...
0
257
by: gsb58 | last post by:
Hi! I haven't worked with streams before. On a form I have: A. cboValues = A combobox with text values where the user can choose a value B. txtText = A textbox where the user can enter...
4
10222
by: Dale | last post by:
I am creating GIF images with transparent backgrounds on-the-fly for a web app and rendering them by using System.Drawing.Image.Save(Response.OutputStream, ImageType.GIF). I am confident that...
12
4014
by: Lee | last post by:
I have the following code using System; using System.Windows.Forms; using System.Drawing; using System.Collections; namespace FINN {
4
5463
by: kev | last post by:
Hi folks, I have created a database to store information on equipments. During the first level of registration, there is a form that i need the user to fill up details on the equipment testing....
0
7037
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,...
0
7034
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,...
1
6732
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5324
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,...
1
4768
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...
0
4472
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...
0
2976
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1294
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 ...
1
558
muto222
php
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.