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
81
votes
6 answers

Howto? Parameters and LIKE statement SQL

I am writing a searching function, and have thought up of this query using parameters to prevent, or at least limit, SQL injection attacks. However, when I run it through my program it does not return anything: SELECT * FROM compliance_corner WHERE…
Anders
  • 12,088
  • 34
  • 98
  • 146
81
votes
7 answers

String.Format - how it works and how to implement custom formatstrings

With String.Format() it is possible to format for example DateTime objects in many different ways. Every time I am looking for a desired format I need to search around on Internet. Almost always I find an example I can use. For…
hwcverwe
  • 5,287
  • 7
  • 35
  • 63
80
votes
3 answers

Is there a lock statement in VB.NET?

Does VB.NET have the equivalent of C#'s lock statement?
iburlakov
  • 4,164
  • 7
  • 38
  • 40
80
votes
4 answers

VB.NET null coalescing operator?

Possible Duplicates: Coalesce operator and Conditional operator in VB.NET Is there a VB.NET equivalent for C#'s ?? operator? Is there a built-in VB.NET equivalent to the C# null coalescing operator?
RiddlerDev
  • 7,370
  • 5
  • 46
  • 62
80
votes
5 answers

VB.NET vs C# integer division

Anyone care to explain why these two pieces of code exhibit different results? VB.NET v4.0 Dim p As Integer = 16 Dim i As Integer = 10 Dim y As Integer = p / i //Result: 2 C# v4.0 int p = 16; int i = 10; int y = p / i; //Result: 1
Maxim Gershkovich
  • 45,951
  • 44
  • 147
  • 243
80
votes
14 answers

handling dbnull data in vb.net

I want to generate some formatted output of data retrieved from an MS-Access database and stored in a DataTable object/variable, myDataTable. However, some of the fields in myDataTable cotain dbNull data. So, the following VB.net code snippet will…
Azim J
  • 8,260
  • 7
  • 38
  • 61
79
votes
5 answers

Get the name of the current method

This is kind of a silly question, but is it possible to get the name of the method that is currently being executed from within that method? Public Sub SomeMethod() Dim methodName as String = System.Reflection.[function to get the current method…
camainc
  • 3,750
  • 7
  • 35
  • 46
78
votes
8 answers

return only Digits 0-9 from a String

I need a regular expression that I can use in VBScript and .NET that will return only the numbers that are found in a string. For Example any of the following "strings" should return only 1231231234 123 123 1234 (123)…
Brian Boatright
  • 36,294
  • 34
  • 81
  • 102
78
votes
10 answers

Is String a primitive type?

I am curious about the string and primitive types. Article like this says string is primitive type. However second article on MSDN does not list string as primitive type. However when I ran the code provided in second article, it displays String is…
Ram
  • 11,404
  • 15
  • 62
  • 93
78
votes
3 answers

How to make String.Contains case insensitive?

How can I make the following case insensitive? myString1.Contains("AbC")
CJ7
  • 22,579
  • 65
  • 193
  • 321
77
votes
24 answers

Use float or decimal for accounting application dollar amount?

We are rewriting our legacy accounting system in VB.NET and SQL Server. We brought in a new team of .NET/ SQL Programmers to do the rewrite. Most of the system is already completed with the dollar amounts using floats. The legacy system language, I…
Gerhard Weiss
  • 9,343
  • 18
  • 65
  • 67
77
votes
10 answers

Visual Studio stuck at "build must be stopped before the solution can be closed"

When the Visual Basic compiler (Vbc.exe) crashes, Visual Studio fails to detect this and becomes stuck in an inoperable state. The "Build" menu appears as it would if the solution were building, but the Cancel Build (Ctrl+Break) menu item has no…
duozmo
  • 1,698
  • 5
  • 22
  • 33
77
votes
2 answers

Null check in VB

All I want to do is check if an object is null, but no matter what I do, if it compiles, it throws a NullReferenceException just trying to check! Here's what I've done: If ((Not (comp.Container Is Nothing)) And (Not (comp.Container.Components Is…
Ky -
  • 30,724
  • 51
  • 192
  • 308
77
votes
3 answers

What is C# 'internal' in VB.net?

What is C# internal keyword equivalent in VB.NET?
dannyrosalex
  • 1,794
  • 4
  • 16
  • 25
76
votes
11 answers

.NET equivalent of the old vb left(string, length) function

As a non-.NET programmer I'm looking for the .NET equivalent of the old Visual Basic function left(string, length). It was lazy in that it worked for any length string. As expected, left("foobar", 3) = "foo" while, most helpfully, left("f", 3) =…
Josh
  • 4,894
  • 6
  • 34
  • 42