将信息从表单保存到磁盘? [英] Save info from a form to disk?
问题描述
嗨!
我以前没用过溪流。
我在表格上有:
A. cboValues =具有文本值的组合框,用户可以选择
a值
B. txtText =用户可以输入文本的文本框
C. cboDatePicker =一个日期时间选择器,用户可以选择一个
日期
现在,当他/她选择时OK按钮,我想将数据保存到磁盘上,文本文件如下:
Dim MyDir为字符串,MyFile为字符串,MyFileExt as string
''这个目录已经存在,因为它是在主表单的OnLoad
期间创建的。
MyDir =" ; C:\APlace \"
''现在文件....
MyFile = cboValues& " _" &安培; cboDatePicker
MyFileExt =" .txt"
MyPath = Trim(MyDir& MyFile& MyFileExt)
我明白了我应该使用一个流。有谁能告诉我这是怎么回事?
从帮助文件中了解不多。
Me.Name
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
推荐答案
Imports System.io
Imports System.Convert
Dim myStream As FileStream
Dim i As Integer
Dim letter As Char
myStream =新FileStream(MyPath,FileMode.OpenOrCreate)
For i = 1 To TextBox1.Text.Length
letter = Mid(TextBox1.Text,i, 1)
arrText = ToByte(letter)
myStream.WriteByte(arrText)
下一页
>
你将拥有自己的道路。当你将datepicker转换成字符串
时,你会有类似_12 / 9/05的东西。这是非法的文件路径(我认为这是个b $ b。)
HTH,Phil
< gs *** @ hotmail.com>在消息中写道
news:11 ********************** @ z14g2000cwz.googlegr oups.com ...
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...
嗨!
我之前没有和溪流合作过。
在我的表格上:
A. cboValues =具有文本值的组合框,用户可以选择值。
B. txtText =用户可以输入文本的文本框C. cboDatePicker =用户可以选择的日期时间选择器
date
现在,当他/她选择OK按钮时,我想将数据保存到磁盘上,如文本文件:
Dim MyDir为字符串,MyFile为字符串,MyFileExt为字符串
''此目录已存在,因为它是在主窗体的OnLoad
期间创建的。
MyDir =" ; C:\APlace \"
''现在文件....
MyFile = cboValues& " _" &安培; cboDatePicker
MyFileExt =" .txt"
MyPath = Trim(MyDir& MyFile& MyFileExt)
我明白我应该使用一个流。有谁能告诉我这是怎么做到的?
对帮助文件不是那么了解。
Me.Name
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
Imports System.io
Imports System.Convert
Dim myStream As FileStream
Dim i As Integer
Dim letter作为Char
myStream =新FileStream(MyPath,FileMode.OpenOrCreate)
For i = 1 To TextBox1.Text.Length
letter = Mid(TextBox1.Text,i,1)
arrText = ToByte(letter)
myStream.WriteByte(arrText)
下一页
你将拥有自己的路径。当你将datepicker转换成字符串
时,你会有类似_12 / 9/05的东西。这是非法的文件路径(我认为这是个b $ b。)
HTH,Phil
< gs *** @ hotmail.com>在消息中写道
news:11 ********************** @ z14g2000cwz.googlegr oups.com ...
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...
嗨!
我之前没有和溪流合作过。
在我的表格上:
A. cboValues =具有文本值的组合框,用户可以选择值。
B. txtText =用户可以输入文本的文本框C. cboDatePicker =用户可以选择的日期时间选择器
date
现在,当他/她选择OK按钮时,我想将数据保存到磁盘上,如文本文件:
Dim MyDir为字符串,MyFile为字符串,MyFileExt为字符串
''此目录已存在,因为它是在主窗体的OnLoad
期间创建的。
MyDir =" ; C:\APlace \"
''现在文件....
MyFile = cboValues& " _" &安培; cboDatePicker
MyFileExt =" .txt"
MyPath = Trim(MyDir& MyFile& MyFileExt)
我明白我应该使用一个流。有谁能告诉我这是怎么做到的?
对帮助文件不是那么了解。
Me.Name
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
谢谢!
我知道。
文件的完整路径包含一些文字我没有打算写。
完整的文件名将是这样的:
TodayFile_12 / 9 / 05.txt
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
这篇关于将信息从表单保存到磁盘?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!