Visual Basic.NET





Visual Basic .NET (VB.NET) is an object-oriented programming language implemented on the .NET framework, but also supported on other platforms such as Mono and Silverlight. Microsoft launched VB.NET as the successor to the Visual Basic language. Though it is similar in syntax to  Visual Basic pre-2002, it is not the same technology,

Share tech news, updates, or what's on your mind.

Sign up to Post

How many times have you tried using Office InterOp to manage various custom properties? If you have ever tried it then you will see the article image very appropriate. After spending hours trying to solve a question I finally gave up on Office InterOp and took an easier way out - OpenXML SDK.
Learn SQL Server Core 2016
LVL 13
Learn SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

Web Development
An ASP.NET Web Form User Control is not newly introduced in ASP.NET. In fact, it was an old technology yet still playing a role to generate web content, especially when we want to use it to have a better and easy way to control part of the web content that is being generated.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.

Expert Comment

by:sudhir singh
if we want to run this script for a group of computer only not domain wide ?
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that understanding with Experts-Exchange users.
LVL 11

Author Comment

Hi St. Jimbo,

Thanks for your valuable inputs.

As this is my very first article so I was not aware of all these points. I have submitted my article with the specified modifications.  Please review it again.

LVL 76
Any method which matches the above delegate type can be assigned to this MyTestDelegate delegate.
What do you mean by "matches"?

To call those methods through delegate, we have to use Invloke() method of that delegate.
You can also just invoke the delegate like a function using parentheses, which if memory serves is just syntactic sugar for Invoke:


Asynchronous execution of method through delegate
Don't forget about the async/await functionality of .NET!
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
LVL 68

Expert Comment

by:Jim Horn
Very well written, and I can see how this can be very useful.  Voted Yes.
LVL 111

Expert Comment

by:Ray Paseur
When a custom control is placed on the toolbox, if it is a professionally made control, it usually has a really nice icon associated with it instead of the default custom control icon that Visual Studio inserts when no icon is available.  When you build your own custom control, you can add an icon for the control and embed it in your component's DLL assembly so that it is shown on the toolbox whenever someone adds your control.

you need to follow below steps to add icon in your custom control.

Step 1:

Create your icon and save it as a bmp file (16x16), named as shown below.


  e.g. Project Name : CustomGrid
        Control Name : MyGridControl

Bmp File Name :  CustomGrid.MyGridControl.bmp

Step 2: Add in Project and Change Build Action Properties to "Embedded Resources".

Stpe 3: Add ToolboxBitmap line in your class file as per screenshot.

 Toolbox Sample Code
Step 4 : Compile your Project as "Class Library".

Step 5:  Add this control in Different Solution Project Toolbox using choose items and icon will display like below ( In Same Project icon can not display).


Download Sample Project :
dog-poodle-snow-sweater-pe<wbr />t-413141
Ever wonder how to "do" object oriented programming (OOP)?
LVL 15

Author Comment

by:David L. Hansen
Quite right Doug.  Thanks for your thoughts!
LVL 15

Author Comment

by:David L. Hansen
With this one you're reading, I'm starting a series of articles focused on creating and manipulating graphics in .Net using GDI+ library starting at the most basic level of knowledge in this area. I'll post all the source code in Visual, as it is my preferred language, although the code would look much similar and is really easy to translate from to C# using one of the many excellent online translators (for example, this one).


GDI+ was introduced by Microsoft in Windows XP as an improvement and a replacement of GDI. GDI (Graphics Device Interface) was present in all prior versions of Windows and was a core OS component responsible for representing graphical objects, as well as transmitting them to output devices, such as monitors and printers. Note that GDI was not responsible for drawing windows, menus, and other Windows OS core graphical objects (those features are in the user subsystem).

As said, Windows XP replaced the old GDI libraries with GDI+, which improved GDI by adding new features and optimizing existing features. MSDN defines GDI+ as "the portion of the Windows XP operating system or Windows Server 2003 operating system that provides two-dimensional vector graphics, imaging, and typography". The .Net Framework graphics system uses GDI+ through the System.Drawing namespace.

Legacy graphics?

MSDN describes GDI+ as a legacy graphics …
The SSGlassPanel control at work.
Well... probably you have noticed that I have not much time to write articles. But I feel specially proud of my GlassLabel control article, as it has been awarded with Community Pick and it has more than 3000 views until now.

In the mentioned article, I suggested several issues for further programming. The most important, I think, the ability to align the text anywhere on the control (as the original GlassLabel control allowed only centering the text either horizontally or vertically).

But... recently I was reviewing some *very* old VB6 programs that I made... well... 18 or 20 years ago. I noticed that, in most of them, I used the old Sheridan 3D Panel (SSPanel). Do you remember? Oh, how many times in the past I was looking for threed32.ocx (as it was not installed in the standard VB6 installation) and registering it with regsvr32! Well, in more recent times it seems that we all have declined that old-fashioned 3D look, now all must be plain and simple, don't you think so? But the SSPanel control had something... I don't know, but... special.

So I decided to extend the GlassLabel control with the ability to draw inset or raised borders around it (the main feature of the SSPanel control) and, at the same time, fix the text alignment bug. And here's the result: the SSGlassPanel control. I have …
LVL 58

Expert Comment

Looks good! Voted 'yes' above. Great work, Roland.
LVL 25

Author Comment

by:Luis Pérez
Thank you very much, tigermatt!!

YaLanCha - Yet Another LAN Chat Application?

I needed a simple person-to-person chat system for use only in my home network behind my router firewall. My only requirements were that the system not require a central server and that it not require any kind of installation other than "copy and run". My intended use of this chat system would entail only simple text conversations with the ability to send a link to a web site. I did not need or want any fancier features such as chat rooms, emoticons, file transfers, voice chats, group broadcasts, or online statuses. I just wanted a system that was always on and was ready to send/receive text messages to any other computer in the household. A quick search of the web yielded a huge number of possibilities; many of them free and quite capable. Ultimately, though, I found myself not wanting a bloated chat system that I didn't really trust not to be infected with a virus or malware.

With that in mind, I decided to roll my own chat system from scratch. I had written simple chat systems before using the Winsock control in VB6, but I left that language long ago for the newer .Net world. Unfortunately, the .Net framework does not provide a direct replacement for the Winsock control. This seemed a perfect time and opportunity to tackle the TcpClient and TcpListener classes -- something that had been on my "To Do" list for quite some time. Furthermore, I decided that I would use a standard WinForms project targetting the .Net …

Expert Comment

This is perfect...can u please tell me why it is detecting only two computers on my network?

Expert Comment

by:Mridul Anand
Hi Mike,

Thanks for posting the whole code along with logic well explained. I have a strange requirement, but I dare ask - I want to use this chatting feature be available from within Excel, i.e. whenever Excel is open, it should work as Listener and Server and be used for opening chat conversations with people on my network, provided they have the same program running in their active Excel application (possibly by putting this code inside PEROSNAL.XLSB. Possible?

Thanks a lot.
Announcing the Winners!
LVL 13
Announcing the Winners!

The results are in for the 15th Annual Expert Awards! Congratulations to the winners, and thank you to everyone who participated in the nominations. We are so grateful for the valuable contributions experts make on a daily basis. Click to read more about this year’s recipients!

A request I've seen often here on Experts-Exchange and out on the internet is for the ability to customize the BackColor and ForeColor of a Disabled TextBox.  A common complaint is that the text in a disabled TextBox is hard to read because the default forecolor is a gray on top of a light gray background.  A good number of these requests are immediately met with fierce opposition to changing the default colors as it might confuse the user since your disabled TextBox will look different from other standard disabled TextBoxes.  This article will not take a stand on this issue.  Let's assume that you've carefully weighed the drawbacks, or have a valid reason to deviate from the norm, and still want to change the colors of your disabled TextBox.  How, then, can we accomplish our goal?

Let's first take a look at the two most common solutions to this problem...

Common Solution #1 - The ReadOnly() Property Approach

Many solutions suggest that instead of setting Enabled() to False, we instead set ReadOnly() to True which prevents changes to the TextBox, but allows the BackColor and ForeColor to be customized.  A small caveat to that approach is that the BackColor must be set before changes to the ForeColor are honored.  Setting the BackColor to the already assigned BackColor seems to do the trick:

        TextBox1.BackColor = TextBox1.BackColor
        TextBox1.ForeColor = Color.Red

A problem with the ReadOnly() approach, though, is that the TextBox still …

Expert Comment

Very useful and out of the box ! Thanks!
What is XMouse behavior?

"XMouse" behavior is a system whereby windows receive focus when the mouse enters them, as opposed to requiring the user to physically click on them.  Focus is automatically given to a window when the mouse enters it, and stays within for longer than the pre-defined threshold delay.  When the window receives focus, it can also optionally be brought to the top of the z-order, in front of all other windows.

Why would I want to use XMouse?

Using an XMouse setup can reduce the number of clicks and amount of time needed to accomplish a task.  For example, when I reconcile my checkbook, I have my bank statement open in my primary monitor, and MS Money open in my secondary monitor.  Balancing the accounts requires frequent scrolling in both windows to find matches, but clicks are only necessary in the secondary monitor to place a checkmark next to records in MS Money that appear in the bank statement.  Thus the only interaction required in the primary monitor is scrolling that window with the mousewheel on my mouse.  With default mouse operations in Windows, though, one must click the bank statement window before it can be scrolled.  Therefore each and every time I want to scroll the opposite screen, I must first execute a click on it.  More often than I'd like to admit, I actually forget to click on that opposite screen, resulting in the wrong window being scrolled when I use the mousewheel!  With XMouse behavior activated, however, …


If you want to create a single file installer using Visual Studio, you can either use InstallShield LE, or repackage your setup.exe and MSI file into a self extracting file.  This article explains how to do the latter, with WinRAR, producing a professional looking package.

First of all, you may be tempted to just provide the MSI file for the installation.  You should only do this if you expect your end users to ensure all .NET runtime requirements are present on the install target machine.  This might be adequate in some corporate environments, or for your friends, or for a group of developers, but otherwise Setup.exe bootstrapper should be included with your MSI file.

Creating the install file manually

First of all, we’ll look at the steps involved to create the setup interactively.

Select the Setup.exe and your MSI file and right click.  Select the “Add to Archive…” context menu choice.  Now you can edit the archive name, and check the “Create SFX” checkbox.
General TabClick the “Advanced Options” tab.
Advanced tabClick the “SFX Options” button.  This opens a dialog that allows you to change many of the default behaviours of the generated self extract files.
SFX General
On the General Tab, check “Create in the current folder” and add the option to run Setup.exe after extraction.  This will launch your installer when the user runs the self extractor.
SFX Text and Icon tabOn the Text and Icon tab,…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity)
  <gesmes:subject>Reference rates</gesmes:subject>
     <gesmes:name>European Central Bank</gesmes:name>
     <Cube time="2011-09-09">
      <Cube currency="USD" rate="1.3817"/>
      <Cube currency="JPY" rate="107.48"/>
      <Cube currency="BGN" rate="1.9558"/>
      <Cube currency="CZK" rate="24.430"/>
      <Cube currency="DKK" rate="7.4473"/>
      <Cube currency="GBP" rate="0.86590"/>

Open in new window

There are three files available HERE (and updated once daily) that contain:
1. The days FX rates
2. The last 90 days' FX rates
3. All daily FX rates since 1999

The XML file provided is by no means a regular XML file, and the code provided in the developer section is PHP. After several days' research and search for simple code to parse the XML file from the ECB, it became clear that there needs to be a simpler way to parse these files.

I set out to resolve this by utilising the WebClient Class to download the files and parse them using the XMLTextReader Class.

Firstly, I use the webclient's DownloadDataAsync method and add handlers for the progress changed (for monitoring rogress) and another handler for when the method completes. This is inside a Boolean function which requires an integer value (0,1 or 2) to select the file to download (daily, 90 day and since 1999 respectively). Heres the code:

Open in new window

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex.

A simple solution to parsing a customized CSV file is to use this function which returns the datatable. You will have to first setup the datatable, and in this simplified scenario, all the fields of the file are imported into the table. (here is a snapshot of the file).
30/10/2011,First transaction,001,9.99
01/11/2011,"Second transaction, Withdraw",002,-3.26
03/11/2011,Third transaction,003,1.08
And since we intend to load this data into a datatable, here is the setup of the table in code. (You can achieve the same using the designer).
Dim gTable As New DataTable("MyTable")
With gTable
    .Columns.Add("Date").DataType = GetType(System.DateTime)
    .PrimaryKey = New DataColumn() {.Columns("DelayID")}
    .Columns.Add("Description").DataType = GetType(System.String)
    .Columns.Add("FITID").DataType = GetType(System.String)
    .Columns.Add("Amount").DataType = GetType(System.Double)
    .Columns("FITID").AllowDBNull = False
    .Columns("Amount").DefaultValue = 0
End With

Open in new window

If you are wondering why the "overkill" in using regex, then the answer lies on the second line of the file which contains a qualified field (a field enclosed in quotes) that contains a comma (which in turn is the file delimiter). The regex ensures that this line is parsed properly, and the code for this is:
Dim pattern As String = ",(?=(?:[^""]*""[^""]*"")*(?![^""]*""))"
Dim r As System.Text.RegularExpressions.Regex = New System.Text.RegularExpressions.Regex(pattern)

Open in new window

Since the file has a header row, we need to define this and exclude it from the data using LINQ, but firstly, we should declare it as a string constant to later incorporate into the LINQ query.
Dim header As String = "Date,Description,FITID,Amount"

Open in new window

LVL 17

Author Comment

At the risk of sounding like I am banging on about the obvious, may I add that aside from the fictitious situation whereby a newbie user forgot to include a closing quotation character on a field that is supposed to be a qualified field because he had no access to a computer, the article does address and provide a solution for parsing of a CSV file using Regex and LINQ. I am sure you agree with that.

And last time I checked, there was NO option strict errors with the code, or am I missing something here?

Expert Comment

Nepaluz, thank you for taking the time and effort to post this. I found it to be very informative and a good alternative to the method I've been using.

I do have a follow up question. The CSV files I'm dealing with are huge, in the order of 10's of GigaBytes. Rather than readalllines, can you adapt this function to read one line at a time and return the an array as a data table would be over-kill in this situation.

One last thing. Any pointers to a good LINQ tutorial?
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with trigonometric functions, or rotating the entire drawing the surface to draw lines at specific angles.  This article will demonstrate just how easy it is to make an analog clock in VB.Net using the latter rotation method.

The “Bare Bones” Analog Clock: A Circle with Several Lines

Let’s begin by building a “bare bones” analog clock as described above: “a circle with several lines in it.”  Start by adding a new UserControl to your Project.  Click on Project --> Add User Control, change the name in the box to “AnalogClock” and press Enter to create it.  Most of our work will be done in the Paint() event so let’s start there.  With the UserControl selected, go to the Properties Pane and click on the “Lightning Bolt” icon to get a list of events. "Lightning Bolt" Icon for EventsScroll down to the “Paint” entry and double click it.  You should now have this in your editor:
Public Class AnalogClock

    Private Sub AnalogClock_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint

    End Sub

End Class

Open in new window

The Paint() event supplies a Graphics surface via “e.Graphics” that allows us to draw on the UserControl.  In the .Net Framework, the default coordinate system places the…

Expert Comment

Adding the circular segments would be great.....

I was surprised by the degree of clarity and logically lucid step by step approach which was used in the article. Why not start a book in the form of teaching by example.

A collection of projects that you explain in the manner employed in your article.
Just an eBook put on sale at a reasonable price.

It's an idea worth thinking about and would really fill a gap in the current flood of books that teach programming.

As far as I know there is nothing on the market in this form...!


Expert Comment


I know we make far too many plans for a holiday like Christmas.
Usually the holiday comes and goes and we discover it wasn't long enough to do half of what we intended...

We the above in mind, I ask if we are going to see a second part for the analogue clock article...?

It’s quite interesting for me as I worked with Excel using for some time.
Here are some topics which I know want to share with others whom this might help.
First of all if you are working with Excel then you need to Download the Following

And then extract it and then add Microsoft.Office.Interop.Excel as reference then start writing the things you want to accomplish using .net and Excel.

This Blog or Article helps you to write values to excel,Merge Cells,Protect Excel sheet with Passwords and Many more stuffs.
Import the Statement in to your form or Class
Imports Microsoft.Office.Interop.Excel
Private Sub WorkingWithExcel()

'Declaring variable for Excel sheet
Dim xlApp As New Microsoft.Office.Interop.Excel.ApplicationClass
Dim xlWorkBook As Microsoft.Office.Interop.Excel.Workbook
Dim xlWorkSheet As Microsoft.Office.Interop.Excel.Worksheet
'Set the File path
xlWorkBook = xlApp.Workbooks.Open("File Path")
xlWorkSheet = xlWorkBook.Worksheets("Sheet1$")
With xlWorkSheet
'ASSIGN VALUE TO A CELL. Here below the value is assigned to 8th Row 12th 'column
.Cells(8, 12).Value ="This is test sentence."

'Add Rows to the Excel sheet.Here it inserts the row at 10th position

'Delete Rows to the Excel 

Open in new window


Author Comment

by:Avinash Desai
Thanks for publishing ...

Dear Readers

If any question or any errors please let me know so that i can correct it

Avinash Desai
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build great reports for your applications. Reports may contain tabular, aggregated, and multidimensional data, plus they can include charts, and can be used in WinForm or ASP.NET.
The purpose of this “How To” article is to show the basic steps of creating a report, define the data source at runtime, work with parameters, include images, use the expression editor, and how to feed data to a sub report and chart. Finally it will also demonstrate some easy ways for you to customize the ReportViewer control.


To start, I have created an easy SQL table with some data for this example. It's a list of electronic equipment like PDA, Desktop, etc. From that table, you need to create a DataSet with two different DataTables. Just name it “dsReport.xsd”.

The first DataTable, “products”, contains a list of all of the products in the table. Then the second one, “groupTotal”, is an aggregated (Group By) query with the groups and the sum of quantities that will be used in a sub report, and in a chart.

After this, you need to add a report to your application. Just select it and give it an appropriate name. For this example, I have chosen "rptProducts".

  add new item
1.0 - Introduction
Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET).

If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting VB6 to VB.NET seem to think that because these two languages have the same name (at least in part) that they are the same language; that is, VB.NET is just VB6 'NETicised'.  Maybe all you have to do is open the VB6 project in a .NET version of Visual Studio and the conversion wizard will do it all for you...

That thinking is wrong!  The two are very different languages, with completely different behaviours.

2.0 - Notice
In this article I have assumed that the version of the IDE being used is Visual Studio 2008 at a minimum, with V3.0 of the .NET Framework.

3.0 - Some Important Differences
There are a number of significant differences between the way VB6 and VB.NET work. These differences could create unexpected behaviour in the code if not dealt with. Some of these are outlined in this section.

3.1 - Fixed Length Strings
Unlike VB6, VB.NET does NOT support fixed length strings. You will probably find a VB6 code declaration of:
strTranDate As String * 8  ‘ a fixed length string 8 bytes long

Open in new window

... being converted to ...
<VBFixedString(8),System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray,SizeConst:=8)> Public strTranDate() As Char

Open in new window

LVL 38

Expert Comment

Hi Orcbighter,

There are a number of errors in 3.2 - Buffer Allocation that you could address.  For one thing, you can declare arrays in VB6 that have zero lower bound... In fact this is the default.  This statement:
Dim x(4) As Integer

Open in new window

creates an array with 5 elements, from zero to four.  The .NET conversion wizard will convert this without complaint.

When you explicitly declare the lower bound to be 1, however, the wizard will change the number of elements.
Dim y(1 To 4) As Integer

Open in new window

Dim y(4) As Short

Open in new window

and it will add a conversion warning as well so that you are aware of the behaviour.  

I'm not sure what you meant with this:
Dim MyBuffer as new Char(6) {}

Open in new window

This doesn't compile in either VB6 or VB.NET.

In general, I don't think I would recommend people use the conversion wizard at all, except for very limited cases.  I guess it could be seen as the start of a rewrite, but most of the COM components and Win API calls used in VBA/VB6 have native counterparts in .NET that are not addressed by the wizard at all.

Author Comment

Hi PaulHews
Yes I agree with you. For every problem there is a solution.
However, the point of my article was to address those who blindly convert from VB6 to VB.NET, either through lasiness or lack of skill (usually the latter).

My aim was to draw these areas to the reader's attension and alert them to possible problems. From here, the reader can go back and visit there code and, if such buffer allocation code exists, they can modify it, either along the lines you suggested, or along their own lines of thought.

The points I have raised in my article are ALL from bitter experience. I have had a number of contracts where I was commissioned to come in a fix bad conversions.
Learn Ruby Fundamentals
LVL 13
Learn Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.


When many people think of the WebBrowser control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's also very useful for displaying your own custom User Interface (UI). Those members that have used QuickEE will have seen it in action - it is the basis of the Question View pane.

In this article, I will explain how you can raise events from the WebBrowsers DHTML document, and have them handled by your application.  For instance, a user might click an HTML <button> object and your application program can then take action to handle that click.

Setting it up

The interaction between the DHTML and you application is handled by the Component Object Model (COM), so before you can handle the events you need to ensure the class holding your client code is COM-visible.  There are two methods for achieving this.  Make either your assembly or a class visble to COM interactions.

1. Make your [i]assembly[/i] COM-Visible

One option is to make your entire assembly visible to COM by going to the Assembly Information dialog (Project > [AppName] Properties > Application tab > Assembly Information) and ensure the "Make assembly COM-Visible" checkbox is checked:COM-Visible Assembly...OR...

2. Make the [i]class[/i] COM-Visible

The second (and recommended) method is to make just the parent class COM-visible. The parent class in most cases will be the Form's class that contains the WebBrowser control. This is done by adding the ComVisibleAttribute to the class....

Open in new window



As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.  

One recent task I needed to perform at home was to find and document large files in certain folders.  I do a back up regularly of documents and source code, and large binaries in those folders can cause overflow on the media I use for storage.  So I wanted a program that could scan through all the files in the folder and build a list of files over a certain size.  I thought this would be a good opportunity to use some multithreading and see how the performance was improved.

In terms of parallel processing, .NET developers have several choices.  BackgroundWorker objects are useful for performing lengthy calculations out of the UI thread so that the UI can remain responsive.  You can create your own threads, just by instantiating new Thread objects with delegates to the routines you wish to call.  You can also use the built in ThreadPool.  

If you want an aggressively multithreaded application, the ThreadPool object is ideal.  It is designed so that you can queue work items, and as worker threads become available to the pool, the threads will execute the items you queued.  It’s convenient as the framework handles the business of queuing and signaling the threads to start.  


LVL 50

Expert Comment

I was able to build and run the project.  I got similar timing results.

I do have one question...
I'm inexperienced with .NET and the ThreadPool, but it appears to me that the code starts a thread for every folder in the StartFolder dir.  I would expect that Task Manger would show dozens of new threads.  But instead, it starts with 15, and climbs to only about 20.  I get similar numbers if I insert a ThreadPool.GetAvailableThreads call in the scan loop.  That's true even for a full-disk scan (takes over a minute)

Is this as expected?  

Incidently, singled-theaded my quad-core maxes at 25% (as expected).  Multi-threaded, it goes up to 95% (firing on all four cylinders)  -- that's just to confirm that it is working as advertized :-)

-- Dan
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itself.  The default minimum display time is two seconds, and the splash will stay open longer if necessary until the main form has completely loaded.  All of this is well documented on MSDN, commonly known, and discussed pretty extensively in tutorials easily found on the internet.

The "Splash Screen" Setting in Project Properties:
Splash Screen set via Project --> Properties
What isn't commonly found, though, are good examples of how to update the splash screen with progress information from the main form as it loads.  Many examples and tutorials simply use a static splash screen and leave it at that.  MSDN provides an example of how to "update the splash screen with status information" in the MSDN documentation of: My.Application.SplashScreen() property.

In that example, the code is being run from the Application.Startup() event, and changes to the splash screen are done in a direct manner:
Private Sub MyApplication_Startup(ByVal sender As Object, ByVal e As Microsoft.VisualBasic.ApplicationServices.StartupEventArgs) Handles Me.Startup
    ' Get the splash screen.
    Dim splash As SplashScreen1 = CType(My.Application.SplashScreen, SplashScreen1)
    ' Display current status information.
    splash.Status = "Current user: " & My.User.Name
End Sub

Open in new window

Careful!  Multi-threading ahead...

The code is misleading because it implies that we can do this from anywhere.  What isn't well documented or being made clear is that the splash screen and the main form of an application actually run in two different threads.

Expert Comment

I used the threading example above, but oddly, the SplashScreenPLM form just 'flashed' for an instant then disappeared. To keep things simple, I elected to NOT try using a progress bar with updated message, using instead a static image on the background of my splash form. This works just fine.

Thanks all the same, everyone!

Expert Comment

by:Gisa Jovanovic
To the Autor,
I'm trying to use your code in windows app.
It is working as described, but I'm having Login form in my Main Form Load event and
when Login form opend it is not active.
What could be done to reslove this isue.
Thank you for asistance (if this post comes to you)
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way.
The GlassLabel control at work.I've always enjoyed working with graphics, but it's never too clever to re-invent the wheel, so the first thing I did was google for a control that satisfied all my needs. Unfortunately (or not?) I didn't find anything.  I was looking for a label-like control that automatically reflects it's text contents like in a glass. Of course, reflected text must appear semi-transparent. All other control capabilities were welcome too. As I said, didn't find anything event remotely similar.

Mmmm... thinking deeply about it I realized that it would not be too difficult to build my own, so hands on!  First of all, I wrote my requirements list (and I added more and more things as soon as they popped into my head!).  The final requirement list was like this:

It must be a true label control.
It will show a reflection or glass effect of the text drawn.
The control's background can be filled with solid or gradient colors.
The control's text can be filled with solid or gradient colors, too.
The text can draw (or not) a solid-color outline with configurable width.
The level of transparency must be configurable, too.
I ended up with what you see above.  Not bad, uh?  Fortunately I can say that all …
LVL 25

Author Comment

by:Luis Pérez
Thank you very much, Idle_Mind.

Expert Comment

by:Elazreg mm
hi thanks for your share,, then how could i use it in my form?
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place!

Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and looks like this:

SELECT DISTINCT Customers.CustomerID FROM SalesItem
WHERE (((SalesItems.Name)="Redeemed" Or (SalesItems.Name)="Issued") AND ((Transact.DateStamp)>DateAdd('h',28,[?])));

This query takes a Date parameter that needs to be supplied when the query is run. So if you're writing a program in VB .NET that calls this query you need to somehow provide the parameter also. So to do this you need an OleDBCommand object and then you can add parameters onto your query.

The solution to writing a query that uses this pre-existing query will need to look like the below code:
Private Function queryDB(ByVal sql As String, ByVal tbl_qry As String) As DataSet
        Dim connStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & databasePath
        Dim oleConn As New OleDb.OleDbConnection(connStr)
        ds = New DataSet
        Dim dsAdapter As New OleDb.OleDbDataAdapter(sql, oleConn)
        'dsAdapter.Fill(ds, tbl_qry)

        Dim cmd As System.Data.OleDb.OleDbCommand = New System.Data.OleDb.OleDbCommand(sql, oleConn)
        dsAdapter.SelectCommand = cmd

        ' Add parameters and set values.
        Dim inactiveDate As String = Format(dtp.Value, "M/d/yyyy")

Open in new window

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code.

First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable.
Also, it can inherit Typed TableBase(Of T)  where T is DataRow or a Typed DataRow.  I don't use Typed DataRow. It has worse performance (by about 30%) on Table Fill  than DataRow, and also needs some tricks to build it.

Next, I create a class for each DataTable that inherits from the base class that contains the common code.   In this class, I declare and create each DataColumn for the DataTable.

Now I create the class constructor (New) where I add the columns to Table.Columns and optionally, assign PrimaryKey Columns.

When I have created each Table, I can create a Class for DataSet (Inherits DataSet).   Here, I declare and create an instance for each DataTable.   Optionally, I declare and create DataRelations.   Then in the Constructor,  add each table to DataSet.Tables and relations to DataSet.Relations.


When you load a DataTable, DataAdapter or DataReader don't query the database to get column information.
You can access Fields by Table.Column declared on Typed DataTable.  This is faster than by ColumnName, avoids errors in typing the ColumnName, and has the best support for Refactoring.
Declare DataTypes for each DataColumn, then you can use DirectCast or

Visual Basic.NET





Visual Basic .NET (VB.NET) is an object-oriented programming language implemented on the .NET framework, but also supported on other platforms such as Mono and Silverlight. Microsoft launched VB.NET as the successor to the Visual Basic language. Though it is similar in syntax to  Visual Basic pre-2002, it is not the same technology,