Questions tagged [vb.net]

Visual Basic.NET (VB.NET) is a multi-paradigm, managed, type-safe, object-oriented computer programming language. Along with C# and F#, it is one of the main languages targeting the .NET Framework. VB.NET can be viewed as an evolution of Microsoft's Visual Basic 6 (VB6) but implemented on the Microsoft .NET Framework. DO NOT USE this tag for VB6, VBA or VBScript questions.

Microsoft's Visual Basic .NET (VB.NET) is a multi-paradigm, managed, type-safe, object-oriented computer programming language. Along with C# and F#, it is one of the main languages targeting the .NET Framework. VB.NET can be viewed as an evolution of Microsoft's Visual Basic 6, but implemented on the Microsoft .NET Framework. This is reflected in VB.NET's version numbering, which continues from VB6. Although Microsoft decided to drop the ".NET" portion of the language's name in 2005, it is still often referred to that way in order to distinguish it from its predecessors.

This tag should only be used for questions that relate to .NET versions of VB. It should not be confused with , , or . Although those languages share a similar syntax with VB.NET, they are entirely different technologies.

To date, the following versions of VB.NET have been released:

VB.NET is supported on a wide range of platforms:

Popular VB.NET questions on Stack Overflow

Resources

139808 questions
278
votes
14 answers

Is it possible to write to the console in colour in .NET?

Writing a small command line tool, it would be nice to output in different colours. Is this possible?
NibblyPig
  • 51,118
  • 72
  • 200
  • 356
244
votes
8 answers

HTML encoding issues - "Â" character showing up instead of " "

I've got a legacy app just starting to misbehave, for whatever reason I'm not sure. It generates a bunch of HTML that gets turned into PDF reports by ActivePDF. The process works like this: Pull an HTML template from a DB with tokens in it to be…
Cᴏʀʏ
  • 105,112
  • 20
  • 162
  • 194
235
votes
8 answers

How do I convert Word files to PDF programmatically?

I have found several open-source/freeware programs that allow you to convert .doc files to .pdf files, but they're all of the application/printer driver variety, with no SDK attached. I have found several programs that do have an SDK allowing you to…
Shaul Behr
  • 36,951
  • 69
  • 249
  • 387
224
votes
14 answers

Check if a string contains an element from a list (of strings)

For the following block of code: For I = 0 To listOfStrings.Count - 1 If myString.Contains(lstOfStrings.Item(I)) Then Return True End If Next Return False The output is: Case 1: myString: C:\Files\myfile.doc listOfString: C:\Files\,…
user57175
  • 3,284
  • 9
  • 32
  • 26
223
votes
12 answers

.Net Data structures: ArrayList, List, HashTable, Dictionary, SortedList, SortedDictionary -- Speed, memory, and when to use each?

.NET has a lot of complex data structures. Unfortunately, some of them are quite similar and I'm not always sure when to use one and when to use another. Most of my C# and VB books talk about them to a certain extent, but they never really go into…
Pretzel
  • 8,141
  • 16
  • 59
  • 84
221
votes
6 answers

Difference between Lookup() and Dictionary(Of list())

I'm trying to wrap my head around which data structures are the most efficient and when / where to use which ones. Now, it could be that I simply just don't understand the structures well enough, but how is an ILookup(of key, ...) different from a…
John Bustos
  • 19,036
  • 17
  • 89
  • 151
220
votes
25 answers

Get the generated SQL statement from a SqlCommand object?

I have the following code: Using cmd As SqlCommand = Connection.CreateCommand cmd.CommandText = "UPDATE someTable SET Value = @Value" cmd.CommandText &= " WHERE Id = @Id" cmd.Parameters.AddWithValue("@Id", 1234) …
dummy
  • 4,256
  • 3
  • 25
  • 36
218
votes
5 answers

.NET Global exception handler in console application

Question: I want to define a global exception handler for unhandled exceptions in my console application. In asp.net, one can define one in global.asax, and in windows applications /services, one can define as below AppDomain currentDomain =…
Stefan Steiger
  • 78,642
  • 66
  • 377
  • 442
211
votes
15 answers

Best way in asp.net to force https for an entire site?

About 6 months ago I rolled out a site where every request needed to be over https. The only way at the time I could find to ensure that every request to a page was over https was to check it in the page load event. If the request was not over…
codethrift
  • 2,337
  • 4
  • 17
  • 16
209
votes
7 answers

What exceptions should be thrown for invalid or unexpected parameters in .NET?

What types of exceptions should be thrown for invalid or unexpected parameters in .NET? When would I choose one instead of another? Follow-up: Which exception would you use if you have a function expecting an integer corresponding to a month and…
Even Mien
  • 44,393
  • 43
  • 115
  • 119
202
votes
15 answers

Is there a way to navigate to real implementation of method behind an interface?

In Visual Studio, when you right-click a method call, you go to the implementation of that method inside a class except if you access this method through an interface: in that case you go to the interface method not to the actual implementation. Is…
user310291
  • 36,946
  • 82
  • 271
  • 487
201
votes
5 answers

Which is generally best to use — StringComparison.OrdinalIgnoreCase or StringComparison.InvariantCultureIgnoreCase?

I have some code like this: If key.Equals("search", StringComparison.OrdinalIgnoreCase) Then DoSomething() End If I don't care about the case. Should I use OrdinalIgnoreCase, InvariantCultureIgnoreCase, or CurrentCultureIgnoreCase?
Dave Haynes
  • 3,633
  • 6
  • 27
  • 23
201
votes
6 answers

Is there a VB.NET equivalent for C#'s '??' operator?

Is there a VB.NET equivalent for C#'s ?? operator?
Nathan Koop
  • 24,803
  • 25
  • 90
  • 125
196
votes
19 answers

"Items collection must be empty before using ItemsSource."

I'm trying to get images to display in a WPF ListView styled like a WrapPanel as described in this old ATC Avalon Team article: How to Create a Custom View. When I try to populate the ListView with a LINQ-to-Entities queried collection of ADO.NET…
Zack Peterson
  • 56,055
  • 78
  • 209
  • 280
195
votes
5 answers

How to write Unicode characters to the console?

I was wondering if it was possible, in a console application, to write characters like ℃ using .NET. When I try to write this character, the console outputs a question mark.
Sam
  • 3,070
  • 3
  • 20
  • 26