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 which 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 in a wide range of platforms:

Popular VB.NET questions on Stack Overflow

Resources

134281 questions
175
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
  • 13,158
  • 19
  • 85
  • 163
174
votes
12 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
  • 2,774
  • 9
  • 30
  • 26
172
votes
12 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…
170
votes
7 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,307
  • 5
  • 45
  • 72
163
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,311
  • 3
  • 19
  • 20
161
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
  • 104,787
  • 56
  • 140
  • 177
161
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
  • 2,670
  • 3
  • 18
  • 24
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
  • 9,829
  • 15
  • 43
  • 55
160
votes
11 answers

What is the C# version of VB.net's InputDialog?

What is the C# version of VB.net's InputBox?
wusher
  • 11,851
  • 22
  • 66
  • 94
159
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,242
  • 2
  • 30
  • 32
153
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
  • 53,106
  • 76
  • 203
  • 279
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,562
  • 7
  • 41
  • 83
152
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,102
  • 14
  • 39
  • 48
151
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,519
  • 2
  • 9
  • 3
147
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
  • 50,394
  • 95
  • 256
  • 391