how to use example code from help

C

cj

Lets just take this example I'm looking at now. I'm looking at the help
screen titled .NET Framework Class Library FolderBrowserDialog Class
[Visual Basic]. It gives an example at the bottom that begins with:

' The following example displays an application that provides the
ability to
' open rich text files (rtf) into the RichTextBox. The example demonstrates
' using the FolderBrowserDialog to set the default directory for opening
files.
' The OpenFileDialog class is used to open the file.

I don't know how to put this example in a program to try it. Where do I
paste the example to run it? Under form load? I don't think so. But
where?
 
G

Greg Burns

If you are running 2005, then that example is the complete class code. I
would create a new form named "FolderBrowserDialogExampleForm"

Then open it up in code view, select everything and hit delete. Then just
paste in the code from the example.

Viola, instant form!

If you have 2003, you have to be more careful not to delete or paste over
the " Windows Form Designer generated code " region.

Take all the code in the Sub New and cut and paste it after this line:
'Add any initialization after the InitializeComponent() call

Then delete the now empty Sub New from the example.

HTH,
Greg
 
C

cj

Ok, I'll look in a minute and see if I can figure it out. I'll let you
know. I am using 2003 and what you suggested for 2005 is what I had
done but your right it don't work in 2003.

How do you like 2005? Is it an official release yet or is it still
beta? Is it easier than 2003? Better? Just interested in your thoughts.

I'll get to work on that sample now.

Greg said:
If you are running 2005, then that example is the complete class code. I
would create a new form named "FolderBrowserDialogExampleForm"

Then open it up in code view, select everything and hit delete. Then just
paste in the code from the example.

Viola, instant form!

If you have 2003, you have to be more careful not to delete or paste over
the " Windows Form Designer generated code " region.

Take all the code in the Sub New and cut and paste it after this line:
'Add any initialization after the InitializeComponent() call

Then delete the now empty Sub New from the example.

HTH,
Greg

Lets just take this example I'm looking at now. I'm looking at the help
screen titled .NET Framework Class Library FolderBrowserDialog Class
[Visual Basic]. It gives an example at the bottom that begins with:

' The following example displays an application that provides the ability
to
' open rich text files (rtf) into the RichTextBox. The example
demonstrates
' using the FolderBrowserDialog to set the default directory for opening
files.
' The OpenFileDialog class is used to open the file.

I don't know how to put this example in a program to try it. Where do I
paste the example to run it? Under form load? I don't think so. But
where?
 
G

Greg Burns

I downloaded my copy from MSDN a month ago. But I have in my hand the
retail upgrade edition my boss just got delivered today.

I love 2005, but there is SO much to learn. Everything from 2003 just
works as is, but there is so many new things I keep discovering and want to
start using.

Luckily, I haven't seen any of the ugly IDE issues some others are
complaining about.

Greg

cj said:
Ok, I'll look in a minute and see if I can figure it out. I'll let you
know. I am using 2003 and what you suggested for 2005 is what I had done
but your right it don't work in 2003.

How do you like 2005? Is it an official release yet or is it still beta?
Is it easier than 2003? Better? Just interested in your thoughts.

I'll get to work on that sample now.

Greg said:
If you are running 2005, then that example is the complete class code. I
would create a new form named "FolderBrowserDialogExampleForm"

Then open it up in code view, select everything and hit delete. Then
just paste in the code from the example.

Viola, instant form!

If you have 2003, you have to be more careful not to delete or paste over
the " Windows Form Designer generated code " region.

Take all the code in the Sub New and cut and paste it after this line:
'Add any initialization after the InitializeComponent() call

Then delete the now empty Sub New from the example.

HTH,
Greg

Lets just take this example I'm looking at now. I'm looking at the help
screen titled .NET Framework Class Library FolderBrowserDialog Class
[Visual Basic]. It gives an example at the bottom that begins with:

' The following example displays an application that provides the ability
to
' open rich text files (rtf) into the RichTextBox. The example
demonstrates
' using the FolderBrowserDialog to set the default directory for opening
files.
' The OpenFileDialog class is used to open the file.

I don't know how to put this example in a program to try it. Where do I
paste the example to run it? Under form load? I don't think so. But
where?
 
C

cj

Well, I guess I'll keep learning 2003 till I get 2005. At least what
I'm learning now will transfer over.

Back to the example code question. This example has everything inside a
Public Class FolderBrowserDialogExampleForm. I don't think I can just
take the sub new code out and put it inside that windows generated code
area wher you said. I tried but it gives me many errors.

I created a new solution and selected view code. I get this:
Public Class Form1
Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

End Class

Where do I paste the rest of the stuff in the example? Does Microsoft
have any documentation on how to use this sample code? I couldn't find
any.



Greg said:
I downloaded my copy from MSDN a month ago. But I have in my hand the
retail upgrade edition my boss just got delivered today.

I love 2005, but there is SO much to learn. Everything from 2003 just
works as is, but there is so many new things I keep discovering and want to
start using.

Luckily, I haven't seen any of the ugly IDE issues some others are
complaining about.

Greg

Ok, I'll look in a minute and see if I can figure it out. I'll let you
know. I am using 2003 and what you suggested for 2005 is what I had done
but your right it don't work in 2003.

How do you like 2005? Is it an official release yet or is it still beta?
Is it easier than 2003? Better? Just interested in your thoughts.

I'll get to work on that sample now.

Greg said:
If you are running 2005, then that example is the complete class code. I
would create a new form named "FolderBrowserDialogExampleForm"

Then open it up in code view, select everything and hit delete. Then
just paste in the code from the example.

Viola, instant form!

If you have 2003, you have to be more careful not to delete or paste over
the " Windows Form Designer generated code " region.

Take all the code in the Sub New and cut and paste it after this line:
'Add any initialization after the InitializeComponent() call

Then delete the now empty Sub New from the example.

HTH,
Greg



Lets just take this example I'm looking at now. I'm looking at the help
screen titled .NET Framework Class Library FolderBrowserDialog Class
[Visual Basic]. It gives an example at the bottom that begins with:

' The following example displays an application that provides the ability
to
' open rich text files (rtf) into the RichTextBox. The example
demonstrates
' using the FolderBrowserDialog to set the default directory for opening
files.
' The OpenFileDialog class is used to open the file.

I don't know how to put this example in a program to try it. Where do I
paste the example to run it? Under form load? I don't think so. But
where?
 
G

Greg Burns

Not to beat a dead horse, but in fact my advice for VB 2005 wasn't
technically correct either. Some of that code should be placed in the
form1.designer.vb partial class file to allow the IDE to be able to modify
it as well.
 
C

cj

Thank you! I ran the program so it's working. I'll take a good look at
it to see how you did what you did. Hopefully it'll make sense to me.
It's about time I wrap things up here at the office to leave for
Christmas. I might be working on this over the holiday some though.

Have a Merry Christmas! And thanks again.
cj
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top