FileOpen问题 [英] FileOpen problem

查看:77
本文介绍了FileOpen问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从一本书中学习VB6。以下代码是

应该打开我创建的一个简单文本文件 - 将

文本放入我的VB文本框中。


Private Sub cmdOpen_Click()

CommonDialog1.ShowOpen

如果CommonDialog1.FileName<> ""然后Text1.Text =

CommonDialog1.FileName

End Sub


相反,文本文件的路径和文件名是

放在我的文本框中。有谁知道为什么这个

不能按照描述工作?我甚至直接从随附的CD中复制并粘贴了

作者的代码,而

的结果是相同的。


我感谢任何人的帮助,


CM

I''m learning VB6 from a book. The following code is
supposed to open a simple text file I created - putting
the text into my VB text box.

Private Sub cmdOpen_Click()
CommonDialog1.ShowOpen
If CommonDialog1.FileName <> "" Then Text1.Text =
CommonDialog1.FileName
End Sub

Instead, the path and file name to the text file is
placed in my text box. Does anyone understand why this
doesn''t work as described? I even copied and pasted the
author''s code directly from an accompanying CD, and the
results are the same.

I appreciate anyone''s help,

CM

推荐答案

Hi CM ,


这是一个VB.net语言组,代码安静不同于经典

VB。


关于VB.classic有很多小组。为了得到更好的答案,如果你在答案之后找不到它,那么b $ b就可以了。在这样的新闻组中,请给你更好的问题


Hi CM,

This is a VB.net language group, that code is quiet different from classic
VB.

There are a lot of groups about VB.classic. To get a better answer you
could if you cannot find it after the answer i give you bellow better ask it
in such a newsgroup.
Private Sub cmdOpen_Click()
CommonDialog1.ShowOpen
如果CommonDialog1.FileName<> ""然后Text1.Text =
CommonDialog1.FileName
结束Sub


你准确地描述了这里发生的事情。


使用commonDialog时获得的路径和文件放在

文本框中。


您需要该路径/文件来打开文件而不是读取然后把数据放在你的文本框中,但是为了那个我会在你的练习中再看一遍,如果我是你的b $ b。

相反,文本文件的路径和文件名是
放在我的文本框中。有谁知道为什么这个
不像描述的那样工作?我甚至直接从随附的CD上复制并粘贴了
作者的代码,结果也一样。
Private Sub cmdOpen_Click()
CommonDialog1.ShowOpen
If CommonDialog1.FileName <> "" Then Text1.Text =
CommonDialog1.FileName
End Sub
You described it exact what happened here.

The path and file you get when you use the commonDialog is placed in the
textbox.

You need that path/file to open a file and than read that and place the data
in your textbox, but for that I would look again in your excercise if I was
you.
Instead, the path and file name to the text file is
placed in my text box. Does anyone understand why this
doesn''t work as described? I even copied and pasted the
author''s code directly from an accompanying CD, and the
results are the same.




我希望到目前为止这对你有帮助


Cor



I hope this helps you so far

Cor


" Cor" < no*@non.com> schrieb
"Cor" <no*@non.com> schrieb

这是一个VB.net语言组,该代码与
经典VB不同。

有很多小组关于VB.classic。为了得到一个更好的答案
你可以在答案之后找不到它我给你吼叫
更好地在这样的新闻组中问它。

This is a VB.net language group, that code is quiet different from
classic VB.

There are a lot of groups about VB.classic. To get a better answer
you could if you cannot find it after the answer i give you bellow
better ask it in such a newsgroup.




....并将它们命名为microsoft.public.vb。*


:-)

-

Armin



....and they are named microsoft.public.vb.*

:-)
--
Armin


*" CM" <一个******* @ discussions.microsoft.com> scripsit:
* "CM" <an*******@discussions.microsoft.com> scripsit:
我正在从一本书中学习VB6。以下代码是


这是一个VB.NET组。你可能想转向一个

microsoft.public.vb。*组。

应该打开一个我创建的简单文本文件 - 把
文本进入我的VB文本框。

私有子cmdOpen_Click()
CommonDialog1.ShowOpen
如果CommonDialog1.FileName<> ""然后Text1.Text =


更好:


\\\

如果Len(CommonDialog1。 FileName)> 0然后_

...

///

CommonDialog1.FileName
End Sub

而是将文本文件的路径和文件名放在我的文本框中。有谁知道为什么这个
不像描述的那样工作?我甚至直接从随附的CD上复制并粘贴了
作者的代码,结果是一样的。
I''m learning VB6 from a book. The following code is
This is a VB.NET group. You may want to turn to one of the
microsoft.public.vb.* groups.
supposed to open a simple text file I created - putting
the text into my VB text box.

Private Sub cmdOpen_Click()
CommonDialog1.ShowOpen
If CommonDialog1.FileName <> "" Then Text1.Text =
Better:

\\\
If Len(CommonDialog1.FileName) > 0 Then _
...
///
CommonDialog1.FileName
End Sub

Instead, the path and file name to the text file is
placed in my text box. Does anyone understand why this
doesn''t work as described? I even copied and pasted the
author''s code directly from an accompanying CD, and the
results are the same.




什么会你希望被放在文本框中?仅限文件名?

查看CommonDialog'''FileTitle''属性。


-

Herfried K. Wagner [MVP]

< http://www.mvps.org/dotnet>



What would you expect to be placed in the textbox? The file name only?
Have a look at the CommonDialog''s ''FileTitle'' property.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>


这篇关于FileOpen问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆