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
131
votes
3 answers

How does inheritance work for Attributes?

What does the Inherited bool property on attributes refers to? Does it mean that if I define my class with an attribute AbcAtribute (that has Inherited = true), and if I inherit another class from that class, that the derived class will also have…
devoured elysium
  • 101,373
  • 131
  • 340
  • 557
130
votes
7 answers

Breaking/exit nested for in vb.net

How do I get out of nested for or loop in vb.net? I tried using exit for but it jumped or breaked only one for loop only. How can I make it for the following: for each item in itemList for each item1 in itemList1 if item1.text = "bla…
KoolKabin
  • 17,157
  • 35
  • 107
  • 145
129
votes
3 answers

.NET Core doesn't know about Windows 1252, how to fix?

This program works just fine when compiled for .NET 4 but does not when compiled for .NET Core. I understand the error about encoding not supported but not how to fix it. Public Class Program Public Shared Function Main(ByVal args As String())…
Joshua
  • 40,822
  • 8
  • 72
  • 132
127
votes
13 answers

Is VB really case insensitive?

I'm not trying to start an argument here, but for whatever reason, it's typically stated that Visual Basic is case insensitive and C languages aren't (and somehow that is a good thing). But here's my question: Where exactly is Visual Basic case…
Todd Main
  • 28,951
  • 11
  • 82
  • 146
125
votes
6 answers

String.Join method that ignores empty strings?

The VB.NET method String.Join(separator, stringArray) is similar to PHP's implode, but any null elements in the array are replaced with an empty string, so thatc: Dim myArray() as String = { "a", null, "c" } Console.WriteLine(String.Join(", ",…
Doug
  • 2,400
  • 2
  • 18
  • 24
124
votes
12 answers

Strip double quotes from a string in .NET

I'm trying to match on some inconsistently formatted HTML and need to strip out some double quotes. Current: The Goal: This is wrong because I'm not escaping it properly: s = s.Replace(""",""); This is…
Even Mien
  • 44,393
  • 43
  • 115
  • 119
122
votes
12 answers

What is the difference between "instantiated" and "initialized"?

I've been hearing these two words used in Microsoft tutorials for VB.NET. What is the difference between these two words when used in reference to variables?
Alex Gordon
  • 57,446
  • 287
  • 670
  • 1,062
121
votes
10 answers

Write text files without Byte Order Mark (BOM)?

I am trying to create a text file using VB.Net with UTF8 encoding, without BOM. Can anybody help me, how to do this? I can write file with UTF8 encoding but, how to remove Byte Order Mark from it? edit1: I have tried code like this; Dim utf8…
VJOY
  • 3,752
  • 12
  • 57
  • 90
121
votes
64 answers

Hidden Features of VB.NET?

I have learned quite a bit browsing through Hidden Features of C# and was surprised when I couldn't find something similar for VB.NET. So what are some of its hidden or lesser known features?
Sean Gough
  • 1,721
  • 3
  • 26
  • 47
120
votes
2 answers

How to check if an object is a certain type

I am passing various objects to a subroutine to run the same process but using a different object each time. For example, in one case I am using a ListView and in another case I am passing a DropDownList. I want to check if the object being passed…
Leah
  • 2,547
  • 5
  • 23
  • 28
114
votes
4 answers

Set a DateTime database field to "Now"

In VB.net code, I create requests with SQL parameters. It I set a DateTime parameter to the value DateTime.Now, what will my request look like ? UPDATE table SET date = "2010/12/20 10:25:00"; or UPDATE table SET date = GETDATE(); In the first case…
Thibault Witzig
  • 2,060
  • 2
  • 19
  • 30
114
votes
3 answers

Reliable timer in a console application

I am aware that in .NET there are three timer types (see Comparing the Timer Classes in the .NET Framework Class Library). I have chosen a threaded timer as the other types can drift if the main thread is busy, and I need this to be reliable. The…
John
  • 29,788
  • 18
  • 89
  • 130
114
votes
7 answers

Why is there a difference in checking null against a value in VB.NET and C#?

In VB.NET this happens: Dim x As System.Nullable(Of Decimal) = Nothing Dim y As System.Nullable(Of Decimal) = Nothing y = 5 If x <> y Then Console.WriteLine("true") Else Console.WriteLine("false") '' <-- I got this. Why? End If But in C#…
blindmeis
  • 22,175
  • 7
  • 55
  • 74
113
votes
3 answers

Difference between DirectCast() and CType() in VB.NET

I am an experienced C/C++/C# programmer who has just gotten into VB.NET. I generally use CType (and CInt, CBool, CStr) for casts because it is fewer characters and was the first way of casting which I was exposed to, but I am aware of DirectCast and…
Caleb Hearth
  • 3,315
  • 5
  • 30
  • 44
113
votes
7 answers

How do I apply a CSS class to Html.ActionLink in ASP.NET MVC?

I'm building an ASP.NET MVC application, using VB.NET and I'm trying to apply a css class to a Html.ActionLink using the code: <%=Html.ActionLink("Home", "Index", "Home", new {@class = "tab" })%> But when I run the code I receive the below…
LiamGu
  • 5,317
  • 12
  • 49
  • 68