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
195
votes
16 answers

Setting Objects to Null/Nothing after use in .NET

Should you set all the objects to null (Nothing in VB.NET) once you have finished with them? I understand that in .NET it is essential to dispose of any instances of objects that implement the IDisposable interface to release some resources…
John
  • 29,788
  • 18
  • 89
  • 130
186
votes
4 answers

What is a predicate in c#?

I am very new to using predicates and just learned how to write: Predicate pre = delegate(int a){ a %2 == 0 }; What will the predicate return, and how is it useful when programming?
Jebli
  • 2,775
  • 6
  • 29
  • 37
185
votes
13 answers

ObservableCollection Doesn't support AddRange method, so I get notified for each item added, besides what about INotifyCollectionChanging?

I want to be able to add a range and get updated for the entire bulk. I also want to be able to cancel the action before it's done (i.e. collection changing besides the 'changed'). Related Q Which .Net collection for adding multiple objects at once…
177
votes
11 answers

What is the C# version of VB.NET's InputBox?

What is the C# version of VB.NET's InputBox?
wusher
  • 12,291
  • 22
  • 72
  • 95
176
votes
8 answers

How to loop through all the properties of a class?

I have a class. Public Class Foo Private _Name As String Public Property Name() As String Get Return _Name End Get Set(ByVal value As String) _Name = value End Set End Property …
Sachin Chavan
  • 5,578
  • 5
  • 49
  • 75
176
votes
7 answers

Why use String.Format?

Why would anyone use String.Format in C# and VB .NET as opposed to the concatenation operators (& in VB, and + in C#)? What is the main difference? Why are everyone so interested in using String.Format? I am very curious.
Mathias Lykkegaard Lorenzen
  • 15,031
  • 23
  • 100
  • 187
169
votes
8 answers

Classes vs. Modules in VB.NET

Is it considered an acceptable practice to use Modules instead of Classes with Shared member functions in VB.NET? I tend to avoid Modules, because they feel like leftover remains from Visual Basic 6.0 and don't really seem to fit in anymore. On the…
Tom Juergens
  • 4,492
  • 3
  • 35
  • 32
168
votes
17 answers

Mixing C# & VB In The Same Project

Can you mix vb and c# files in the same project for a class library? Is there some setting that makes it possible? I tried and none of the intellisense works quite right, although the background compiler seems to handle it well enough (aside from…
Wes P
  • 9,622
  • 14
  • 41
  • 48
164
votes
5 answers

#if Not Debug in c#?

I have the line in vb code: #if Not Debug which I must convert, and I don't see it in c#? Is there something equivalent to it, or is there some workaround?
user278618
  • 19,306
  • 42
  • 126
  • 196
164
votes
12 answers

Is String.Format as efficient as StringBuilder

Suppose I have a stringbuilder in C# that does this: StringBuilder sb = new StringBuilder(); string cat = "cat"; sb.Append("the ").Append(cat).(" in the hat"); string s = sb.ToString(); would that be as efficient or any more efficient as…
lomaxx
  • 113,627
  • 57
  • 144
  • 179
164
votes
13 answers

.NET Configuration (app.config/web.config/settings.settings)

I have a .NET application which has different configuration files for Debug and Release builds. E.g. the debug app.config file points to a development SQL Server which has debugging enabled and the release target points to the live SQL Server. There…
Gavin
  • 2,321
  • 3
  • 19
  • 21
161
votes
7 answers

How should I cast in VB.NET?

Are all of these equal? Under what circumstances should I choose each over the others? var.ToString() CStr(var) CType(var, String) DirectCast(var, String) EDIT: Suggestion from NotMyself… TryCast(var, String)
Zack Peterson
  • 56,055
  • 78
  • 209
  • 280
161
votes
6 answers

Linq to Sql: Multiple left outer joins

I'm having some trouble figuring out how to use more than one left outer join using LINQ to SQL. I understand how to use one left outer join. I'm using VB.NET. Below is my SQL syntax. T-SQL SELECT o.OrderNumber, v.VendorName, …
Bryan Roth
  • 10,479
  • 15
  • 47
  • 56
159
votes
21 answers

Multiline strings in VB.NET

Is there a way to have multiline strings in VB.NET like Python a = """ multi line string """ or PHP? $a = <<
pistacchio
  • 56,889
  • 107
  • 278
  • 420
158
votes
45 answers

The name does not exist in the namespace error in XAML

Using VS2012 working on a VB.NET WPF application. I have a simple MusicPlayer tutorial app I am using to learn WPF. I am converting a C# version of the tutorial to VB.NET step by step. It has 2 classes in the app that are both under the same…
Jeff Davis
  • 1,755
  • 2
  • 11
  • 14