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
76
votes
4 answers

What is the purpose of Decimal.One, Decimal.Zero, Decimal.MinusOne in .Net

Simple question - why does the Decimal type define these constants? Why bother? I'm looking for a reason why this is defined by the language, not possible uses or effects on the compiler. Why put this in there in the first place? The compiler can…
Jasmine
  • 4,003
  • 2
  • 29
  • 39
75
votes
7 answers

6 digits regular expression

I need a regular expression that requires at least ONE digits and SIX maximum. I've worked out this, but neither of them seems to work. ^[0-9][0-9]\?[0-9]\?[0-9]\?[0-9]\?[0-9]\?$ ^[0-999999]$ Any other suggestion?
framara
  • 2,833
  • 5
  • 28
  • 32
75
votes
3 answers

Redirect Trace output to Console

Let's say I'm working on a little batch-processing console app in VB.Net. I want to be able to structure the app like this: Sub WorkerMethod() 'Do some work Trace.WriteLine("Work progress") 'Do more work Trace.WriteLine("Another…
Joel Coehoorn
  • 399,467
  • 113
  • 570
  • 794
74
votes
10 answers

Is there a way to programmatically minimize a window

What I'm doing is I have a full-screen form, with no title bar, and consequently lacks the minimize/maximize/close buttons found in the upper-right hand corner. I'm wanting to replace that functionality with a keyboard short-cut and a context menu…
Stephen Wrighton
  • 36,783
  • 6
  • 67
  • 86
74
votes
26 answers

Count specific character occurrences in a string

What is the simplest way to count the number of occurrences of a specific character in a string? That is, I need to write a function, countTheCharacters(), so that str = "the little red hen" count = countTheCharacters(str,"e") ' Count should equal…
Urbycoz
  • 7,247
  • 20
  • 70
  • 108
74
votes
15 answers

Are C#'s partial classes bad design?

I'm wondering why the 'partial class' concept even exists in C#/VB.NET. I'm working on an application and we are reading a (actually very good) book relavant to the development platform we are implementing at work. In the book, the author provides a…
dferraro
  • 6,357
  • 11
  • 46
  • 69
73
votes
10 answers

The VB.NET 'With' Statement - embrace or avoid?

At work, I'm frequently working on projects where numerous properties of certain objects have to be set during their construction or early during their lifetime. For the sake of convenience and readability, I often use the With statement to set…
Tom
  • 15,527
  • 5
  • 48
  • 62
73
votes
6 answers

VB.Net Properties - Public Get, Private Set

I figured I would ask... but is there a way to have the Get part of a property available as public, but keep the set as private? Otherwise I am thinking I need two properties or a property and a method, just figured this would be cleaner.
RiddlerDev
  • 7,370
  • 5
  • 46
  • 62
72
votes
7 answers

Format decimal value to string with leading spaces

How do I format a decimal value to a string with a single digit after the comma/dot and leading spaces for values less than 100? For example, a decimal value of 12.3456 should be output as " 12.3" with single leading space. 10.011 would be " 10.0".…
Jakob Gade
  • 12,319
  • 15
  • 70
  • 118
72
votes
8 answers

The difference between + and & for joining strings in VB.NET

What is the difference between + and & for joining strings in VB.NET?
Rob P.
  • 14,921
  • 14
  • 73
  • 109
72
votes
6 answers

center MessageBox in parent form

Is there a easy way to center MessageBox in parent form in .net 2.0
Ramji
  • 2,536
  • 7
  • 34
  • 54
72
votes
10 answers

How do I kill a process using Vb.NET or C#?

I have a scenario where I have to check whether user has already opened Microsoft Word. If he has, then I have to kill the winword.exe process and continue to execute my code. Does any one have any straight-forward code for killing a process using…
bugBurger
  • 6,950
  • 9
  • 32
  • 39
71
votes
8 answers

The State of Linkers for .NET apps (aka "Please Sir, May I have a Linker" 2009 edition)

Many people here are probably familiar with one of Joel Spolsky most popular blog posts, Please Sir, May I Have a Linker, where he cries out for a way to remove dependencies on the .NET framework so a stand-alone application can be developed and…
Robert P
  • 15,707
  • 10
  • 68
  • 112
70
votes
8 answers

How do I convert from a string to an integer in Visual Basic?

How do I convert from a string to an integer? Here's what I tried: Price = CInt(Int(txtPrice.Text)) I took out the Int and I still got an exception.
swydell
  • 1,962
  • 8
  • 31
  • 44
70
votes
14 answers

Why use Finally in Try ... Catch

I see that the Finally in Try .. Catch will always execute after any parts of the execution of the try catch block. Is it any different to just skip the Finally section and just run it after, outside the try catch block? Example 1, Try ... Catch ...…
awe
  • 21,938
  • 6
  • 78
  • 91