Share via


Programming Essentials in Visual Basic .NET

Posted March 30, 2004

Chat Date: March 16, 2004

Please note: Portions of this transcript have been edited for clarity

Introduction

Moderator: Ed_H (Microsoft)
Welcome to today’s chat on Programming Essentials in Visual Basic .NET. We have members of the Visual Basic team here to answer your questions today. I will ask the hosts to introduce themselves.

Host: Gordon (Microsoft)
I'm Gordon Brown, a programmer-writer documenting the Visual Basic core language features.

Host: harish (Microsoft)
hi, I am Harish and work in the Visual Basic compiler team.

Host: robgruen (Microsoft)
My name is Robert Gruen and I'm a support engineer for VB.NET

Host: Robin (Microsoft)
My name is Robin Reynolds-Haertle. I'm a programmer/writer for Visual Basic.

Host: SteveLee (Microsoft)
Hi! I'm Steven Lees. I've worked on a bunch of different developer tools products at MS and I'm currently working in program management on Visual Basic.

Moderator: Ed_H (Microsoft)
Amanda will be with us in just a minute too!

Moderator: Ed_H (Microsoft)
And I am Ed Hickey, VS Communities PM. Glad you all could make it today!

Moderator: Ed_H (Microsoft)
Let's get started! Fire away with your questions for our hosts.

Start of Chat.

Host: SteveLee (Microsoft)
Q: jw23 : does anybody know how to create dockable sub windows? Like the tool windows in .Net.
A: There isn't a built-in control that does this, but you could take a look on windowsforms.net. There may also be a control vendor that provides one.

Host: Robin (Microsoft)
Q: Harlequin : Nicholas. I'm sorry If I'm a pain but I could really do with a hand on the syntax. Not everything, because I need to learn, but a start would be good. I can work through the context ID and other stuff myself.
A: Harlequin: There is a Help sample online that uses Visual Basic .NET. It is one of the 101 samples.

Host: Robin (Microsoft)
https://www.microsoft.com/downloads/details.aspx?FamilyId=08E3D5F8-033D-420B-A3B1-3074505C03F3&displaylang=en

Host: SteveLee (Microsoft)
Q: JoA-Farore : Q: I've read a lot of these chats & MS seems dedicated to supporting & enhancing their "flagship" language, VB. However, when it comes to developing products all I hear is C++, C++, VC#. Can you give any examples of popular or powerful software products from Microsoft, written in VB? or does MS prefer to use C++ and if so what does that really say about VB?
A: As Ed mentioned earlier, we use VB to write parts of the VB runtime. We also have some internal applications that are built in VB. But Office isn't one of them...yet. <g>

Host: robgruen (Microsoft)
Q: Regarding the .NET implementation of the regular expressions engine, has Microsoft supplied a good tutorial for using it? If not, what sources do you recommend for getting into the details of regular expressions, as implemented in .NET?
A: Currently there is no great documentation up on MSDN but there are some docs in the works. In the interim I recommend searching for some help sites, the most popular search engines should yield some good results for some howto sites.

Host: robgruen (Microsoft)
There is a regex sample that you can reference: https://msdn.microsoft.com/en-us/library/aa720492(v=VS.71).aspx.

Host: Amanda (Microsoft)
Q: Are there any plans to add pointer functionality to VB, and is there currently a way to emulate this beyond ByRef
A: There are no plans to introduce pointers to Visual Basic .NET. But I'm interested to know exactly which aspect of pointer functionality you would like to access...

Host: harish (Microsoft)
Q: Could you also spend some time talking about localization techniques for more than just Windows Forms? For example, I frequently just type strings into my code, for messageboxes and so forth. It would be nice if there were a utility for scraping those strings
A: You will need to review your code and decide what strings you want to localize and add them to a resoure file and when you need the string, load it from the resource file using the ResourceManager class.

Host: SteveLee (Microsoft)
Q: toe_jam : what kind of changes should we expect then Whidbey arrives
A: Lots of great stuff. Take a look at the VB Dev Center (https://msdn.microsoft.com/vbasic) for a bunch of info. We've got some great language improvements like generics and operator overloading; we've got a much better data design time, including data binding to objects; and a new runtime object that makes it really easy to get at the framework.

Host: Robin (Microsoft)
Q: Multiselect of datagrid nobody answered
A: I've asked the Windows Forms writers. We may get an answer back before the end of chat.

Host: robgruen (Microsoft)
Q: So, I wonder, is there any good documentation about writing add-ins to Visual Studio?
A: The add-in project creation wizard is extremely helpful (https://msdn.microsoft.com/en-us/library/80493a3w(v=VS.80).aspx). Also, for high level information use https://msdn.microsoft.com/en-us/library/aa290342(v=VS.71).aspx to figure out what exactly you’re trying to do and where it would fit in.

Host: robgruen (Microsoft)
Q: So, I wonder, is there any good documentation about writing add-ins to Visual Studio?
A: You can also get a book written by one of the automation devs: https://www.amazon.com/exec/obidos/tg/detail/-/0735618747/qid=1079472132/sr=1-1/ref=sr_1_1/103-5826998-9270253?v=glance&s=books

Host: robgruen (Microsoft)
It contains a lot of information that didn't make it up to MSDN.

Host: harish (Microsoft)
Q: Harish_MS, that's all well and good, but what I wonder is whether or not it would ever be possible to do that programatically, perhaps with an add-in which works alongside the code formatter.
A: Theoretically this should be possible to do programmatically (may require quite some work), but I don't know of any addins which help with this.

Host: SteveLee (Microsoft)
Q: sphinx : I can't help but notice how convenient it would be if I could subclass the DataRows into typed data set generated by visual studio. this would allow me to add business rules without worrying about synchronizing the business object with the data row.sphinx : sphinx: subclassing datasets seems to me to be the next best thing to ObjectSpaces. Problem is that once the dataset is regenerated, custom code is blown away. Any plans for supporting subclassing in future versions (or ways to do it now effectively)?
A: One way that you can handle the sync issue is just to have your business objects be a thin wrapper on the data row. If you have an OrderID property on an Order object, for instance, then the OrderID property accessor can just look up the data in the data row. That way, you never store two copies of the data and you don't have to worry about synchronization. The other advantage is that it makes your business object a little cleaner because it doesn't have to inherit from anything. In Whidbey, the data designer will support binding Windows Forms UI to plain objects like this.

Host: Amanda (Microsoft)
Q: When you add a control using a button from a form to another with both open. Do you just dim without creating an instance? Q:doesn't instantiate make a new form from the old one? or does it affect the current opened one too?
A: When you instantiate a form, using "Dim f As New Form1", it create a new instance of the form. So, if you have access to a previously existing form, f2, then calling functions on that form would only affect f2, not both.

Host: Robin (Microsoft)
Q: One of the largest frustrations is all this information that "didn't make it up to MSDN". Documentation for .NET is kind of poor, IMO. Any improvements in the pipeline?
A: We're always looking to improve! The Everett update to the documentation last fall was the first time we've updated Visual Studio documentation between releases. If you find specific topics or areas that need better documentation, you can use the feedback link at the bottom of any topic. That feedback is sent to the writer of the topic.

Host: Robin (Microsoft)
Q: Will future VB.NET example code be written by VB programmers? A LOT of the MSDN sample code is written in C-style coding.
A: We are working to make our VB code examples more VB-like. We've published new internal standards and are training our programmer/writers. You should see improvements in our next release. If you see code that looks like C, send us feedback using the link at the bottom of the topic. We're always adding to our list of things in VB that look like C.

Moderator: Ed_H (Microsoft)
Q: PLEASE Bring back Edit-and-continue!!!!!
A: My favorite answer to give - E&C will be in Whidbey!

Host: Amanda (Microsoft)
Q: Can you have two forms when you creating an app?
A: Yes. But I'm not sure if you're looking to have two different forms or two instances of the same form. You can have both.

Host: Amanda (Microsoft)
A: To have two forms, simply right-click your project node and select Add Windows Form. To have two instances, add code to instance the form: "Dim f As New Form1()".

Host: robgruen (Microsoft)
Q: VB6 allowed an easy print-screen of the form image from the print menu. How can this be done in VB.NET?
A: Currently there is no equivalent of PrintForm in VB.NET. However, you can get a bitmap of your form by calling the PrintWindow() API. You can then print this to the printer using the print sample: https://msdn.microsoft.com/en-us/library/bb690938.aspx.

Host: Amanda (Microsoft)
Q: this is a question more related to architecture than VB.net. I've been reading about Xen lately and was curious about how sequences would be implemented at the byte code level Q: would it necessitate changes to the underlying IL architecture?
A: No. It is purely code gen'd by the compilers.

Host: Robin (Microsoft)
Rob_Perkins: I've made a list of your documentation comments and I'll share it with the Framework writers. The list is:

Host: Robin (Microsoft)
The problem with the documentation isn't in the written articles, it's in the organization of the topics.

Host: Robin (Microsoft)
This is compounded by the fact that the Framework is so deep *and* wide.

Host: Robin (Microsoft)
There really aren't any decent conceptual introductions to the Framework, like there are to the CLR.

Host: Robin (Microsoft)
It's caused some deeply frustrating problems, when you can watch a support engineer make a one-line change to your code and see it behave properly.

Moderator: Ed_H (Microsoft)
Q: How did VB.net make it to release without E&C to begin with and what happened to "Print" aka "?"? I feel stripped of my VB Heritage
A: VB.Net is not an interpreted language, and it was a lot harder to implement well than in VB6. We didn't want to ship it "broken", so we waited. I think you will also like the "MyDot" object in Widbey, it will bring back a lot of the "VB6" things you liked so much.

Host: robgruen (Microsoft)
Q: How can I stream a wmv file to the internet?
A: Use Windows Media server! https://www.microsoft.com/windows/windowsmedia/distribute.aspx

Host: robgruen (Microsoft)
Q: How can I realize a video stream of an wmv file to the internet with visual basic
A: Here's a VB.NET Sample on how to stream a wmv file: https://msdn.microsoft.com/en-us/library/cc189078%28v=VS.95%29.aspx

Host: harish (Microsoft)
Q: for whatever reason I wanted multiple references outside of procedures to refer to that particular value type
A: This is not allowed because then other objects outside of the procedures could potentially be referring to memory on the stack that may go away once the control returns from the caller of the procedure with the byref param. One alternative could be to cast the value type to System.Object and then use this object in the different locations including when passing it to the byref param. But note that this has perf implications and also will change the semantics of the byref param from true byref (i.e. the object that the caller refers to is changed immediately when the procedure with the byref param makes any changes to the members of the passed in value type) to copy-in copy-out semantics.

Host: Robin (Microsoft)
Q: Do you think you'll make some parts of this internal standard public or semi-public ?
A: It's still undecided, but we're leaning towards adding them to the documentation. What do you think?

Host: Amanda (Microsoft)
Q: When E&C comes back in VB.net will that have influence on performance in the IDE or in the EndUser applications?
A: There will be absolutely no impact on the perf of the end-user application. We're working on making the IDE as fast as we can. So far we're seeing really good results wrt EnC.

Host: robgruen (Microsoft)
Q: I have Visual Basic .Net 2003. Would I be able to create any web applications with Windows XP Home Edition? Or Do I need XP Professional?
A: You can't create a web app on XP Home since XP Home doesn't have IIS.

Host: Gordon (Microsoft)
Q: (VBPro7) Form1 has a bnt. click it to go to form2. form2 has a bnt. click it to add textbox to form1. I create a textbox object in form2 with bnt click event. How do I reference the form1.control.add(newtextbox). do I dim form1 then form1 = new form1
A: VBPro7 -- The answer to this is changing with the advent of Whidbey. As it stands now, you have to provide Form2 with a reference to Form1. If it's Form1 that creates Form2, that's pretty easy -- just define a procedure on Form2 that can accept a form reference pointer, and call it from Form1 passing Me.

Host: Gordon (Microsoft)
You don't want to Dim F As New Form1 or you'll create a second instance of Form1. You want to reference the instance you've already got.

Host: Gordon (Microsoft)
When Whidbey hits the streets, it gets even easier. The "My." functionality provides a number of collections, including My.Forms. So all Form2 has to do is My.Forms.Form1.Controls.Add(newtextbox).

Host: robgruen (Microsoft)
Q: I see always in newsgroup the magic of dispose, can somebody say when it should be used and when not.
A: This doc tells you when you want to use the Dispose method and why: https://msdn.microsoft.com/en-us/library/fs2xkftw.aspx. You shouldn't have any questions after reading it!

Host: Amanda (Microsoft)
Q: Some have claimed that the managed overhead of .NET has made certain functions of VB.NET slower than VB6.
A: For the most part, managed applications should run as fast or faster than their unmanaged counterparts. If you're aware of certain functions that you would expect to be faster, it would be grand if you could pass them along.

Host: Robin (Microsoft)
Q: fastvince : How do I make my forms and controls display like Win XP forms and controls ?
A: You need to call Application.EnableVisualStyles. The documentation is online:https://msdn.microsoft.com/en-us/library/system.windows.forms.application.enablevisualstyles.aspx

Host: Robin (Microsoft)
There is a sample that uses XP themes in the 101 samples:https://www.microsoft.com/downloads/details.aspx?FamilyId=08E3D5F8-033D-420B-A3B1-3074505C03F3&displaylang=en

Host: SteveLee (Microsoft)
Q: sphinx: Q: Do ADO.NET datasets use generics? If not, why not? Wouldn't it improve performance?
A: Visual Studio already creates strongly-typed datasets for you, so there's no performance advantage to using generics.

Host: robgruen (Microsoft)
Q: I never had my question answered. Is it possible to do a print-screen from VB.Net?
A: You can use the BitBlt() API to capture the screen and store it within a Bitmap object. There are several code samples on the net that show you how to do this.

Moderator: Ed_H (Microsoft)
This has been a GREAT chat. Thank you to everyone. Unfortunately, it is time to go. Thanks for participating, and we'll see you next time!

Host: Robin (Microsoft)
Here's an example: https://msdn.microsoft.com/en-us/library/bb629268.aspx

Host: Amanda (Microsoft)
Thanks everyone. Hope to see you in another chat really soon...

For further information on this topic please visit the following:

Newsgroups: microsoft.public.dotnet.languages.vb

VB .NET Transcripts: Read the archive of past VB .NET chats.

Website: Visit the Microsoft Visual Basic .NET site.

Top of Page Top of Page