Share via


Programming Essentials in Visual Basic (February 1, 2005)

Posted: February 16, 2005

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

Introduction

Ed_H_MS (Moderator):
Hi folks - we will be having the Programming Essentials in Visual Basic chat in about half an hour

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

manishjMSFT (Expert):
Hi I am Manish Jayaswal. I am the test lead in VB compiler team.

Robin_MS (Expert):
I'm Robin Reynolds-Haertle, a programmer/writer for Visual Basic.

Todd_MS (Expert):
My name is Todd Apley and I've been involved with the Visual Basic team since 1993 testing product features since VB3.

Vladimir_MS (Expert):
Hi!, My name is Vladimir and I work in the Visual Basic Compiler test team.

WHorst_MS (Expert):
Hi! My name is Bill Horst and I test the VB Debugger.

Ed_H_MS (Moderator):
And I am Ed Hickey, Visual Basic MVP Lead. Glad you all could make it today!

Ed_H_MS (Moderator):
As you can probably tell, this is a new chat client. To submit a question for our hosts to answer, please use the "Submit a Question" radio button in the bottom room, then click "Send", this way we can get them in the queue to answer. If you just want to add a comment to the chat window, use the "Guest Chat" radio button.

Let's get started! Fire away with your questions for our hosts.

Start of Chat

Todd_MS (Expert):
Q: Whens the next update for Whidbey VB.NET due out ?
A: The next update to Whidbey (Beta2) will be out this summer. Sub foo
End Sub

Vladimir_MS (Expert):
Q: what would you each say is the most exciting feature in vb.net in vs2005 and why?
A: Support for Generics is pretty interesting from the language prospective

Ed_H_MS (Moderator):
Q: Will there be a Jan or Feb CTP?
A: At this time, from what I hear, there will be no Jan or Feb CTP for VS 2005.

WHorst_MS (Expert):
Q: what would you each say is themost exciting feature in vb.net in vs2005 and why?
A: My favorite is Edit and Continue (and not just because I test it!)

manishjMSFT (Expert):
Q: A question of technique, I have a vb program which intersperses output with many calculations. I see from the documentation how to print a report using any number of things but no way to print single lines of text. Point me toward anything. (resent as a qu
A: Hi AlJones. I am not clear on what you are trying to do here. Are you trying to send single lines of text to the printer?

Robin_MS (Expert):
Q: When this attribute is present, the data from the XML file is not retrieved. If I manually delete the attribute, the style sheet works fine. Is a bug? Am I doing something wrong? I'm also been unsuccessful in getting ADO.NET to not include the attribut
A: Richard - I've asked someone from the XML team and am waiting on a reply.

Todd_MS (Expert):
Q: You knew this was coming, but why no refactoring tool for the VB IDE? I've heard that the Me namespace took precedence.
A: Sorry, I'm getting the hang of chat here... ;-)
The reason we aren't including refactoring include the following:
a) We have a *ton* of RAD features in whidbey already such as edit & cont, snippits, my, etc...
b) We really want to ship these features we have b/c people have been wanting them for years now.
c) We weren't able to come up with a refactoring model/UI that was easy and powerful enough for our customers and we didn't have the time to do all the work.
So, we certainly hope to add functionality like this in the future, but for now, we think people will be really pleased with what's there.

Vladimir_MS (Expert):
Q: Maybe it's an offtopic subject, but the question is about the Namespace. When do I have to declare the namespace? I mean, when testing the namespace feature, what happens is that the instance must be called twice, like: MyNamespace.MyNamespace.
A: This could be happening in a project called MyNamespace. By default you have root namespace called MyNamespace. If you declare another one, it will be MyNamespace.MyNamespace. You can check/change the root namespace name in the Project properties.

Todd_MS (Expert):
Q: Should I use only when I am out of the project MyNamespace?
A: Sorry, I don't understand your question. What do you mean by "only"

Todd_MS (Expert):
Q: We have VB6 Application that launches another application using a Shell command. We have XP clients (Service Pack 2) and 2003 Server. The process runs repeatedly (approx 24-36 hours). The launching application (VB6 executable) fails with error num
A: What is the error number?

Ed_H_MS (Moderator):
Q: I,m trying to write code to display serial data (RS232) on a Windows Form. I acquired JH CommBase which receives the serial data, but I cannot display it on a Windows Form. I assume I have to use Threading but don't know where within the form code toinsert
A: I'm not familiar with that serial control, is it a .Net control? How does it bring the data in? Text Stream?

Todd_MS (Expert):
Q: What would be a 'general' reommendation on the total size of the data one includes in a Structure? I have heard 16 Bytes but I see many examples that use much more than 16 bytes.
A: Generally speaking, there are no recommendations, per say, that are significant to most vb apps unless you are dealing with code which is very sensitive to perf. You make your structure fit your program needs.

manishjMSFT (Expert):
Q: Manishj, yes, it's that simple. I can find references to printing a document ( *.rtf, etc or a block of text) but not how to simply print a single line of text, perform more calcs and then print the resuls of that.
A: Al, why can't you print the single line of text just as you would print a block of text?

Todd_MS (Expert):
Q: What do you think of RegFree Com?
A: Are you referring to what is in the VS 7.1 product or the upcoming whidbey product? What is your opinion of it?

Robin_MS (Expert):
Q: Where would you recommend I start to come up to speed with game programming for a PC platform using VB.NET? I just got "Managed DirectX 9 Kickstart" by Miller -- is that the right place?
A: I'm reading Beginning .NET Game Programming by David Weller and others right now. There is a VB version and a C# version. So far, this has the best explanations of DirectX I've found, if you're starting from scratch. (And I've bought a few...)

Todd_MS (Expert):
Q: beta 2 Summer !! i hope its not gone back that far?
A: It should be available most likely in May/June timeframe. Wish it could be released earlier, but it takes time for QA teams to validate the all the functionality before we ship.

manishjMSFT (Expert):
Q: Because every blithering example I find show how to do print from with its own procedure. I'm have alzheimers or something,m but I simple cannot see how to call a routine from my calcs routine to print each line of text as data for it comes available.
A: Al, I am trying to find some sample code. Hold on till I investigate.

Todd_MS (Expert):
Q: The RegfreeReg Free COM is disclosed it at VSLive Orlando in Soma's keynote
A: (if this is the right thread). Personally, I feel this is a really cool feature for those customers that want to migrate their apps to .net and keep some legacy COM code and can live with some of the restrictions (such as requiring XP and above OSs)

WHorst_MS (Expert):
Q: I am currently working with VB 2005 Express. The performance of my db application seems to be really bad. Will it improve if I swith to VB 2005 beta 1, for example?
A: I wouldn't necessarily expect performance to improve between VB 2005 Express Beta1 and VS 2005 Beta1. We are working on a number of performance issues now for our release version of VS 2005, but I can't speak specifically about whether your Data scenario will have improved performance.

Robin_MS (Expert):
Q: what is VB.nets best kept secret, or whats you favourite techie tip...
A: I use the fact that you can bind arrays and collections to ListBoxes and such. I fill the collection with objects, using ToString to control what appears in the list.

Ed_H_MS (Moderator):
Q: I beleive it's Text Stream. The code line is, Protected Overrides Function OnRxLine(ByVal s as string).
A: You should be able to pass s to a TextBox, and it should show up in there - like Textbox1.Text = s

Todd_MS (Expert):
Q: I used to create in VB6 Types to access files as random. It was easy go throug a file using this kind of structure. I think that VB.Net doesn't provide this kind of easy random access, isn't it? Which is the closest solution to VB.Net trying to read/write?
A: The closest thing would be to use the FilePut/FileGet routines which should be able to handle almost everything you could do in VB6. Check out the docs for these functions.

WHorst_MS (Expert):
Q: About the namespace, this is exactly what happen. I tried to create a BaseFramework project, where I was adding all my base classes for the systems. Declaring the Namespace keywork, it happen. If I do not declare BaseFramework.BraseFramework must be used.
A: I'm a bit confused what you're describing here. Could you be more specific or perhaps show a simple example?

Vladimir_MS (Expert):
Q: What I am curious about, there seems to be a Sun language to make applets (plugins) for Microsoft Internet Explorer. Is there as well something simple that you can use in VBNet and has the same simple security issues as those applets?
A: It should be possible. In fact most .Net applications can be hosted in a webpage with minimal or no changes. Here is an article on MSDN that could be interesting for you: https://msdn.microsoft.com/msdnmag/issues/02/07/NetSmartClients/

manishjMSFT (Expert):
Q: as an aside, this is an ongoing discussion within several newsgroups I inhabit.
A: Al I think you will have to use the graphic object. Take one line at a time and then call methods to draw the line in the graphics object. For more information on this, see the help for Graphics object.

WHorst_MS (Expert):
Q: what is VB.nets best kept secret, or whats you favourite techie tip...
A: This isn't really what I'd call a "techie tip", but I want to mention that Ctrl + J will show a statement completion list without the user having to type a class followed by a . This isn't exactly a well kept secret, but I'm told its a minor frustration a lot of users have been seen to encounter, so I figure I should mention it, in case it will help anyone be more productive.

Ed_H_MS (Moderator):
Q: That's what I tried. But I suspect my serial comm code wasn't being executed. If I had a Simple form with just 1 textbox where would I enter the code?
A: Not knowing the control, there should be an event called something like "OnReceive", that will be where the control brings the text in from the buffer - that is where you can check it

Todd_MS (Expert):
Q: I'm working on a database-heavy application that will eventually use SQL Server. If I prototype with Access can I move over gracefully? If so, anything special I should do up front to not get "stuck" when I do switch?
A: (assuming you are using VS7.1 or Whidbey?). There are .net DB programming books which address this, but generally speaking, you can change the data backend fairly easily.

Todd_MS (Expert):
Q: Will the Visual Basic 6 to Visual Basic 2005 migration process be improved over what we have in Visual Basic.NET 2003?
A: Yup. We support the migration of more VB6 features and have fixed several bugs in this area.

WHorst_MS (Expert):
Q: So, when should I use the namespace keyword for my BaseFramework? When adding more projects (with more classes to be used at BaseFramework) on my solution?
A: I'm still not quite clear. What is BaseFramework...a project, namespace, or class? When you refer to "using a namespace keyword", do you mean declaring BaseFramework as a namespace? Declaring a namespace around BaseFramework?

manishjMSFT (Expert):
Q: Have the team started to look at language changes in the Orcas version of vb.net. I'm sure you can't reveal much about it, how excited are you about the next 'next' version.
A: Hi Richy, we have started looking into it and we are pretty excited. Just stay tuned for more info.

Todd_MS (Expert):
Q: how many string concatinations before using stringbuiler - 10 concats or 1kb size?
A: It really depends on the code and how it's used. For typical application code, using SB will not improve an app's perf noticably. However, if you have perf sensitive code (say in a loop that's run all the time), then anything more than 4-5 concats should be moved.

Vladimir_MS (Expert):
Q: Vladimir, you would not believe I know that page. however can that be done without any security acknowledge by a client. I thought that I had readed that that could not. When I am wrong correct me.
A: I think it is possible, but the set of permissions that an application gets depends on the level of trust that is assigned. The default set for an Internet zone application is very restrictive. It would not for example allow opening files on the client machine. Any elevation of security privileges or the default security policy must be done by the client. The application cannot exceeed its priveleges or change them.

Todd_MS (Expert):
Q: Todd - for Whidbey. I got the book "First Look at SQL Server 2005" by Beauchemin et al -- haven't read yet but is that a good starting point?
A: Haven't read this yet, but may be good. If you want, you can mail stevelas (PM on data) who may give you pointers. Otherwise, there will be articles posted up on https://msdn.microsoft.com/vbasic/ which will give tips.

Vladimir_MS (Expert):
Q: In VB 2005, what should I do when I need to use more than one instance of the same form i.e. don't use default instances?
A: Just as before you can do " Dim form2 As New Form1 : form2.Show() " .

WHorst_MS (Expert):
Q: Sure! Project BaseNS. I put the namespace keyword as BaseNS too with a class clsTest. To create an instance of clsTest I have to use Dim x as BaseNS.BaseNS.clsTest, right? So, how to create an own namespace avoiding this? Do not declare the namespace ...
A: So if I understand correctly (and if I don't, please say so), you have the following sort of thing in a project called BaseNS:

And in a different project, you must refer to clsTest as BaseNS.BaseNS.clsTest.
The reason for this is that your project has its own root namespace called BaseNS, and when you declare BaseNS as a namespace in the project code, that effectively declares a namespace BaseNS within the project namespace BaseNS. If you want to refer to clsTest in your code as just BaseNS.clsTest, leave off the namespace declaration altogether. If you want to refer only to Dim x as clsTest, put Imports BaseNS.BaseNS (or just Imports BaseNS) if you remove the namespace declaration). If you want to refer to the namespace as something else, you can say Imports Someothername = BaseNS.BaseNS at the top of your file to create an alias. Namespace BaseNS
Class clsTest
End Class
End Namespace

Todd_MS (Expert):
Q: What is the best technique performance wise for sorting a strongly typed collection and the moving through the collection in the sort order?
A: This article may help you... https://msdn.microsoft.com/en-us/library/14ek9axh(v=VS.85).aspx

Todd_MS (Expert):
Q: The problem with the FilePut/FileGet with random files is that the VB.Net doesn't use fixed length strings anymore. How to handle it? Thanks.
A: It's supported, just a little strange. Check out this: https://msdn.microsoft.com/en-us/library/microsoft.visualbasic.vbfixedstringattribute.aspx

WHorst_MS (Expert):
Q: when the project has the samename of the namespace? I am just trying to understand how to build a library with my company namespace.
A: I forgot to mention, if you want to declare Dim x as YourCompanyName.clsTest, go to project properties and change the root namespace to YourCompanyName. Let me know if none of these answers your question.

Todd_MS (Expert):
Q: Would someone be able to recommend what graphic file types should be used in a windows application and why? I come from a web bkg where i use .jpg and .gif
A: It depends (slightly) on how they are used, but generally speaking it doesn't matter if you are talking about VS.NET. The controls easily bind to all the major types of graphic files.

WHorst_MS (Expert):
Q: How stable is VS 2005 Beta 1???Can i start writing small application for production???Or better to wait until Beta 2???
A: Based on my experience using Beta1, it is fairly stable, and probably will be ok for developing a small application, but you should definitely back up your work frequently, because it certainly isn't bug-free, as it is a Beta version. I would expect Beta2 to be significantly more stable, but again, it is a Beta, so it won't be completely stable.

Todd_MS (Expert):
Q: We heard that Visual Freeze was last week. How can authors get the most current version, if no CTP is planned soon?
A: I'm assuming you have an MS contact that you can follow up with. There should be a CTP that you can use or in our groups, we make TS machines available for various individuals.

Vladimir_MS (Expert):
Q: Is Transperent background in GDI++ supported in VS 2005??
A: In theory yes, but some of the screen activities (like opening more windows) may still be denied depending on the client policy and the scurity zone that you are running in.

Ed_H_MS (Moderator):
About 5 minutes left, folks, ask your final questions, if you would...

manishjMSFT (Expert):
Q: manishj, been there - again the examples I'm finding take an item from within their procedure to print. The only thing I've managed so far is to write it to a file and then print the file. Seems like overkill. 'Call methods ... in the graphics object'?
A: You can either print it all to a file or draw it all in a graphics object and then sent the file or the graphics object to the printer. Are you trying to print one line ( actually getting printed on the paper) and then the printer to wait till you send another line?

Ed_H_MS (Moderator):
Q: will chat be published anywhere
A: The transcript from today's chat will be posted on https://www.msdn.microsoft.com/chats/recent.asp

Vladimir_MS (Expert):
Q: Is Transperent background in GDI++ supported in VS 2005??
A: I think this was supported in VS 2003 so should be supported in 2005. Try changing your form's "Opacity" property.

Robin_MS (Expert):
Q: Sorry, hit the enter key by mistake... I'm trying to apply a XSLT style sheet to a XML file I created from a dataset (using the WriteXML method). The attribute "xmls=https://tempuri.org/MyDataSchema.xsd is being included in the resulting XML file.
A: Didn't hear back from the XML team, but the previous reply is correct. You need to take into account the namespace in your stylesheet. That, or you can manipulate the dataset file to remove the namespace.

Vladimir_MS (Expert):
Q: Or vladimir, did I understand it wrong and when I do only screen activities in my program would that automaticly be allowed without restrictions? Than I go try it probably tomorrow.
A: Ooops, sent the answer to a wrong question. Resending - I do not know details of what is allowed and what is not. In theory yes, simple winform app should work. However note that some of the screen activities (like opening more windows) may still be denied depending on the client policy and the security zone that you are running in, so YMMV

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

Ed_H_MS (Moderator):
The transcript from today's chat will be posted on https://www.msdn.microsoft.com/chats/recent.asp

Top of Page Top of Page