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
66
votes
7 answers

Syntax: "Exit Sub" or "Return" in VB.NET subroutines

Both "Exit Sub" or "Return" seem to accomplish the same thing -- exit a subroutine. Is there any difference in how they work under the covers? That is, Private Sub exitNow() Exit Sub End Sub or Private Sub exitNow() Return End Sub
Jeff
  • 8,020
  • 34
  • 99
  • 157
65
votes
12 answers

How do I create a folder in VB if it doesn't exist?

I wrote myself a little downloading application so that I could easily grab a set of files from my server and put them all onto a new pc with a clean install of Windows, without actually going on the net. Unfortunately I'm having problems creating…
John
65
votes
9 answers

VB.NET: how to prevent user input in a ComboBox

How do you prevent user input in a ComboBox so that only one of the items in the defined list can be selected by the user?
CJ7
  • 22,579
  • 65
  • 193
  • 321
65
votes
12 answers

Random integer in VB.NET

I need to generate a random integer between 1 and n (where n is a positive whole number) to use for a unit test. I don't need something overly complicated to ensure true randomness - just an old-fashioned random number. How would I do that?
brendan
  • 29,308
  • 20
  • 68
  • 109
64
votes
6 answers

INotifyPropertyChanged and Auto-Properties

Is there a way to use INotifyPropertyChanged with auto-properties? Maybe an attribute or something other, not obvious to me. public string Demo{ get;set; } For me, auto-properties would be an extremely practicall thing, but almost always, I…
HCL
  • 36,053
  • 27
  • 163
  • 213
64
votes
5 answers

VB.NET - IIF(,,) - Both "sides" are evaluated. What situations should I watch out for?

I recently learned of the IIF(A,B,C) function. I'm a long time VB/VB.NET Coder who recently spent a lot of time coming up to speed in SQL coding. One (obvious) common thing to do in SQL is something like the following: select (case where @var = 0…
Brian Webster
  • 30,033
  • 48
  • 152
  • 225
63
votes
3 answers

How to insert values into VB.NET Dictionary on instantiation?

Is there a way that I can insert values into a VB.NET Dictionary when I create it? I can, but don't want to, do dict.Add(int, "string") for each item. Basically, I want to do "How to insert values into C# Dictionary on instantiation?" with VB.NET.…
onsaito
  • 793
  • 1
  • 6
  • 7
62
votes
4 answers

I wrote a program that allow two classes to "fight". For whatever reason C# always wins. What's wrong with VB.NET?

I wrote a program that allow two classes to "fight". For whatever reason C# always wins. What's wrong with VB.NET ? static void Main(string[] args) { Player a = new A(); Player b = new B(); if (a.Power > b.Power) …
Prankster
  • 4,031
  • 5
  • 33
  • 44
62
votes
8 answers

Find the location of my application's executable in WPF (C# or vb.net)?

How can I find the location of my application's executable in WPF (C# or VB.Net)? I've used this code with windows forms: Application.ExecutablePath.ToString(); But with WPF I received this error from Visual Studio: System.Window.Application does…
Shahin
  • 12,543
  • 39
  • 127
  • 205
62
votes
4 answers

How to find out if a column exists in a DataRow?

I am reading an XML file into a DataSet and need to get the data out of the DataSet. Since it is a user-editable config file the fields may or may not be there. To handle missing fields well I'd like to make sure each column in the DataRow exists…
Bryan Anderson
  • 15,969
  • 8
  • 68
  • 83
62
votes
11 answers

How do I prevent a form from being resized by the user?

I have a form that needs to be maximized in VB.net. I don't want the user to be able to change its size or move it around. How can I do this?
Alex Gordon
  • 57,446
  • 287
  • 670
  • 1,062
61
votes
5 answers

Response.redirect raises "Thread was being aborted"

I've a VB.NET code called when I need to delete an object from DB. On Page_load I check if it's not post back (to prevent a manual refresh) and, after the deletion of the object I redirect to the caller page using Response.redirect. At this point my…
Andrea Girardi
  • 4,337
  • 13
  • 69
  • 98
61
votes
2 answers

VB.NET - Interrupt form loop and end form

I have a form that goes through an endless loop and processes data. When I click a button that "closes" the form, the form keeps processing even though it is closed. I want the form to completely end and exit out of its loop statement, and then open…
Phil
  • 513
  • 1
  • 4
  • 5
61
votes
10 answers

Web.config transformation option is greyed out

In VS2010, when I right click on my web.config file the "Add Config Transforms" option is greyed out. Any idea how I can get that back?
NotMe
  • 87,343
  • 27
  • 171
  • 245
61
votes
3 answers

Are there any OK image recognition libraries for .NET?

I want to be able to compare an image taken from a webcam to an image stored on my computer. The library doesn't need to be one hundred percent accurate as it won't be used in anything mission critical (e.g. police investigation), I just want…
RodgerB
  • 8,608
  • 9
  • 36
  • 47