FileOpen problem

  • Thread starter Thread starter CM
  • Start date Start date
C

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,

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
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.

I hope this helps you so far

Cor
 
Cor said:
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.

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

:-)
 
* "CM said:
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.

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

I did answer this post, Armin did give an addition to that post and than
again Herfried
start using a better newsreader Herfried.

The OP did write

The following code is
supposed to open a simple text file I created - putting
the text into my VB text box.



Cor
 
* "Cor said:
I did answer this post, Armin did give an addition to that post and than
again Herfried
start using a better newsreader Herfried.

Yep... I am still looing for a better newsreader.
The OP did write

The following code is
supposed to open a simple text file I created - putting
the text into my VB text box.

Ah---he wants to put the text of the selected file into the textbox...

A nice procedure for doing that can be found here (ignore the German
language comments):

<http://www.vbtec.de/readfile.htm>
 
Hi Herfried,
Yep... I am still looing for a better newsreader.
I never visited this newsgroup but if you are able to look in china for some
information, this is maybe a good newsgroup for you.

nl.comp.software.newsreaders

If your newsserver does not give that newsgroup, you can look on this free
newsserver

news.readfreenews.net use port 120

:-)))))

Cor
 
* "Cor said:
I never visited this newsgroup but if you are able to look in china for some
information, this is maybe a good newsgroup for you.

There are lots of newsreaders available, each of them with its
advantages and disadvantages. I chose the _IMHO_ best newsreader, but
it has some disadvantages too...
 
Herfried,

But maybe you can ask that in the newsgroup I did supply

And when you tell you don't speak the language for that newsgroup, you can
do it in English or German also I gues.

Cor
 
* "Cor said:
But maybe you can ask that in the newsgroup I did supply

And when you tell you don't speak the language for that newsgroup, you can
do it in English or German also I gues.

I don't have any questions.

;-)
 
I don't have any questions.

You did send this to this newsgroup
Yep... I am still looing for a better newsreader.
(I understand that looing is a typo for looking)

Are you looking or not looking, so when you are looking you need advice.

And for that I did give you a newsgroup that is better for this problem..

:-)))

Cor
 
* "Cor said:
You did send this to this newsgroup


Are you looking or not looking, so when you are looking you need advice.

And for that I did give you a newsgroup that is better for this problem..

:-()

It was not a question. I have worked with lots of different newsreaders
and I have taken my decision.
 
Back
Top