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
69
votes
5 answers

Getting hash of a list of strings regardless of order

I would like to write a function GetHashCodeOfList() which returns a hash-code of a list of strings regardless of order. Given 2 lists with the same strings should return the same hash-code. ArrayList list1 = new ArrayList() …
MaxK
  • 3,511
  • 4
  • 20
  • 16
69
votes
6 answers

XPath select node with namespace

Its a .vbproj and looks like this 15a7ee82-9020-4fda-a7fb-85a61664692d all i want to get is the…
Peter
  • 37,042
  • 39
  • 142
  • 198
69
votes
16 answers

I've caught an exception!! Now what?

I've started using try-catch blocks (a bit late, I know!), but now I'm not sure what to do with the exception once I've caught it. What should I do? Try connection.Open() Dim sqlCmd As New SqlCommand("do some SQL", connection) Dim sqlDa…
iamjonesy
  • 24,732
  • 40
  • 139
  • 206
68
votes
2 answers

In VB.NET, can I mark a function as deprecated?

Is there an ability in VB.NET to deprecate code? I know that in C# there are 'attributes', and tags in java; is there anything similar in VB.NET, other than leaving a 'todo:...?
brasskazoo
  • 76,030
  • 23
  • 64
  • 76
68
votes
2 answers

Decoding T-SQL CAST in C#/VB.NET

Recently our site has been deluged with the resurgence of the Asprox botnet SQL injection attack. Without going into details, the attack attempts to execute SQL code by encoding the T-SQL commands in an ASCII encoded BINARY string. It looks…
Dillie-O
  • 29,277
  • 14
  • 101
  • 140
67
votes
2 answers

VB equivalent for C#'s default(T)

What is VB's equivalent for C#'s default(T) - the default operator
Hath
  • 12,606
  • 7
  • 36
  • 38
67
votes
3 answers

Difference between Private Sub, Function and Class

What are the differences between the following: Private Sub Private Function Private Class When should each one be used?
Furqan Sehgal
  • 4,917
  • 33
  • 108
  • 167
67
votes
6 answers

The parameterized query expects the parameter which was not supplied

I'm having a problem with my code: Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged list.Items.Clear() cmd.CommandText = "SELECT * FROM borrow where (Department LIKE…
demic0de
  • 1,313
  • 1
  • 15
  • 30
67
votes
4 answers

Sort a List of Object in VB.NET

I have a list of passengers(object) where it has a differents properties.. passenger.name passenger.age passenger.surname And I want to sort this list by age criterion, how can i do this? I know in a list of integer/string List.Sort() works, but if…
bombai
  • 927
  • 1
  • 17
  • 27
66
votes
8 answers

Yield in VB.NET

C# has the keyword called yield. VB.NET lacks this keyword. How have the Visual Basic programmers gotten around the lack of this keyword? Do they implement they own iterator class? Or do they try and code to avoid the need of an iterator? The yield…
MagicKat
  • 9,695
  • 6
  • 32
  • 43
66
votes
17 answers

'Shadows' vs. 'Overrides' in VB.NET

What is the significance of the two keywords Shadows and Overrides? What they do and for which context is one or the other preferable?
Jeff
  • 8,020
  • 34
  • 99
  • 157
66
votes
3 answers

How do I use a common _ViewStart in areas?

In my "root" Views folder, I have a _ViewStart with the following code: @Code Layout = "~/Views/Shared/_Layout.vbhtml" End COde In my Area/Public/Views folder, I have a copy of my _ViewStart from the root Views folder. But when I run the code,…
MojoDK
  • 4,410
  • 10
  • 42
  • 80
66
votes
6 answers

Does End Using close an open SQL Connection

If I wrap a SQLConnection in a Using, should I close it or does the end using handle it? using cn as new system.data.sqlclient.sqlconnection() cn.open '{do a bunch of other stuff with commands and datareaders here} cn.close 'Do I need…
rjrapson
  • 1,987
  • 1
  • 21
  • 28
66
votes
7 answers

HTTP 415 unsupported media type error when calling Web API 2 endpoint

I have an existing Web API 2 service and need to modify one of the methods to take a custom object as another parameter, currently the method has one parameter which is a simple string coming from the URL. After adding the custom object as a…
AK3800
  • 2,138
  • 3
  • 23
  • 28
66
votes
7 answers

How to do a verbatim string literal in VB.NET?

How do you do a verbatim string literal in VB.NET? This is achieved in C# as follows: String str = @"c:\folder1\file1.txt"; This means that the backslashes are treated literally and not as escape characters. How is this achieved in VB.NET?
CJ7
  • 22,579
  • 65
  • 193
  • 321