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
156
votes
12 answers

How to have comments in IntelliSense for function in Visual Studio?

In Visual Studio and C#, when using a built in function such as ToString(), IntelliSense shows a yellow box explaining what it does. How can I have that for functions and properties I write?
Ali
  • 5,286
  • 9
  • 33
  • 36
154
votes
4 answers

VB.NET equivalent to C# var keyword

Is there a VB.NET equivalent to the C# var keyword? I would like to use it to retrieve the result of a LINQ query.
Jack
  • 1,549
  • 2
  • 9
  • 3
154
votes
10 answers

Auto column width in EPPlus

How to make columns to be auto width when texts in columns are long? I use this code Worksheet.Column(colIndex).AutoFitColumn() 'on all columns' Worksheet.cells.AutoFitColumns() Worksheet.Column(colIndex).BestFit = True 'on all columns' None…
Pengan
  • 1,813
  • 4
  • 15
  • 16
152
votes
4 answers

Why C# fails to compare two object types with each other but VB doesn't?

I have two objects in C# and don't know if it's Boolean or any other type. However when I try to compare those C# fails to give the right answer. I have tried the same code with VB.NET and that did it ! Can anyone tell me how to fix this if there is…
Mohsen Sarkar
  • 5,910
  • 7
  • 47
  • 86
148
votes
4 answers

How to flatten nested objects with linq expression

I am trying to flatten nested objects like this: public class Book { public string Name { get; set; } public IList Chapters { get; set; } } public class Chapter { public string Name { get; set; } public IList Pages {…
ab_732
  • 3,639
  • 6
  • 45
  • 61
148
votes
2 answers

Inline list initialization in VB.NET

Possible Duplicate: Collection initialization syntax in Visual Basic 2008? How is the following C# code translated to VB.NET? var theVar = new List{"one", "two", "three"};
Boris Callens
  • 90,659
  • 85
  • 207
  • 305
146
votes
11 answers

Case insensitive string compare in LINQ-to-SQL

I've read that it's unwise to use ToUpper and ToLower to perform case-insensitive string comparisons, but I see no alternative when it comes to LINQ-to-SQL. The ignoreCase and CompareOptions arguments of String.Compare are ignored by LINQ-to-SQL (if…
BlueMonkMN
  • 25,079
  • 9
  • 80
  • 146
144
votes
2 answers

VB.NET IntelliSense : Disable newline on ENTER autocomplete

When editing C# code in Visual Studio 2010, the ENTER key makes IntelliSense complete the current suggestion, without adding a new line. In VB.NET, the default IntelliSense behavior for the ENTER key is to add a new line after completing the current…
user356178
144
votes
7 answers

Measuring code execution time

I want to know how much time a procedure/function/order takes to finish, for testing purposes. This is what I did but my method is wrong 'cause if the difference of seconds is 0 can't return the elapsed milliseconds: Notice the sleep value is 500 ms…
ElektroStudios
  • 19,105
  • 33
  • 200
  • 417
141
votes
3 answers

VB.NET equivalent of C# property shorthand?

Is there a VB.NET equivalent to the C#: public string FirstName { get; set; } I know you can do Public Property name() As String Get Return _name.ToString End Get Set(ByVal value As String) _name = value End Set End…
Birk
  • 2,173
  • 4
  • 21
  • 26
139
votes
28 answers

How to get ALL child controls of a Windows Forms form of a specific type (Button/Textbox)?

I need to get all controls on a form that are of type x. I'm pretty sure I saw that code once in the past that used something like this: dim ctrls() as Control ctrls = Me.Controls(GetType(TextBox)) I know I can iterate over all controls getting…
Luis
  • 1,840
  • 2
  • 14
  • 14
135
votes
10 answers

Custom Compiler Warnings

When using the ObsoleteAtribute in .Net it gives you compiler warnings telling you that the object/method/property is obsolete and somthing else should be used. I'm currently working on a project that requires a lot of refactoring an ex-employees…
Micah
  • 111,873
  • 86
  • 233
  • 325
135
votes
4 answers

Can I publish a private NuGet package?

I have an assembly that I have made which is very specific to my team at my company. I want to be able to use NuGet to make this assembly avaiable to other projects that my team and similar teams at my company are working on. However, the assembly…
stevebot
  • 23,275
  • 29
  • 119
  • 181
134
votes
8 answers

IsNothing versus Is Nothing

Does anyone here use VB.NET and have a strong preference for or against using IsNothing as opposed to Is Nothing (for example, If IsNothing(anObject) or If anObject Is Nothing...)? If so, why? EDIT: If you think they're both equally acceptable, do…
Luke Girvin
  • 13,221
  • 9
  • 64
  • 84
131
votes
2 answers

Will Try / Finally (without the Catch) bubble the exception?

I am almost positive that the answer is YES. If I use a Try Finally block but do not use a Catch block then any exceptions WILL bubble. Correct? Any thoughts on the practice in general? Seth
Seth Spearman
  • 6,710
  • 16
  • 60
  • 105