Hot answers tagged

21 votes

Search a big (13 GB) Outlook PST file

I would assume that this ...
user avatar
  • 50k
17 votes

Search a big (13 GB) Outlook PST file

COM interop is in itself a performance hit, but even when accessing it through COM (e.g. in VBA), the Outlook type library / object model is notoriously, painfully slow. If performance is a ...
user avatar
15 votes

Optimize a Date and Timespan function

I'm not sure how to optimize your code, but let's talk about those variable names. Naming is hard. It's doubly hard in vb.net, because it's case insensitive. That fact makes it difficult not to step ...
user avatar
  • 30.7k
15 votes

Optimize a Date and Timespan function

Your throw-away "test code" doesn't need to Dim a variable and introduce YACI (Yet Another Cryptic Identifier) - this: ...
user avatar
11 votes
Accepted

Find if value exists using SQL True/False Return

This code is open to injection. Consider what happens if I pass sometext'; Drop Table TblTable; -- into that variable. Use a proper parameterized query instead. The ...
user avatar
  • 30.7k
11 votes

Shutdown Delay Program

I can't resist mentioning this. These comments hurt me. ...
user avatar
  • 30.7k
11 votes

Proper way to validate from sub to sub

Your validation has a "major" flaw. You are validating each thing by itself, so If you user "creates" multiple validation errors, this provides a seriously bad UX. While we're at ...
user avatar
  • 25k
11 votes

Making error messages more efficient

There's probably much more to say about this code, but there's one point that deserves immediate and serious attention: You're handling errors the way vba and vb6 did it... but this code can only be ...
user avatar
11 votes
Accepted

Data Access Layer code for MSSQL Databases

This whole function needs a little bit of work: ...
user avatar
  • 28.5k
10 votes

Find if value exists using SQL True/False Return

You should use Command parameters instead of string concatenation to avoid SQL injection attacks ...
user avatar
10 votes

Number to Words

The function name Convert doesn't seem particularly helpful to me. Convert how? From what to what? In fact, we're not converting anything... we're representing ...
user avatar
  • 25.2k
10 votes
Accepted

Positive integer to Roman Numeral conversion function

This code is bound far too tight to your form. The first thing we need to do is separate the logic for converting an integer to a roman numeral from the event procedures of the form. This will allow ...
user avatar
  • 30.7k
10 votes

Security issues in a SQL query and possible function?

Is this secure? Well, nothing is ever really secure, but yes. Generally speaking it is. You're using parameterized queries, which is good. Malachi is right though, stored procedures would be even ...
user avatar
  • 30.7k
10 votes
Accepted

Proper way to validate from sub to sub

In your case it seems like you want to have a re-usable validation method that validates a common part of your form. Step 1 I wouldn't bind the clicks of the buttons to multiple handlers. This ...
user avatar
  • 1,171
10 votes

Data Access Layer code for MSSQL Databases

I will review the tests because they definitely need some work! GetDataTableTest() The Test suffix is redundant, they're all ...
user avatar
10 votes
Accepted

Regular Expression matching customer number strings

^P\d{5}-13-TP\d{2}-\d{3}(-(L|R|\d{4})(-\d{3,4})*)?$ Your current regex is WAY too forgiving. First of all, every one of your example starts with a P followed by ...
user avatar
9 votes
Accepted

Automatic variable generation from data table

Use array, this will reduce by a lot your number of variables. Name your variable properly ("ten" should be "tenant") Normaly, variable starts with a lower case in .net Do not concatenate your strings ...
user avatar
  • 875
9 votes

Download Images as fast as possible

Just a few quick remarks (for now): vbNullString is a remnant of VB6 (which I think would be under the ...
user avatar
8 votes

Optimize a Date and Timespan function

I don't know how much of an optimization it is, but what really jumps out at me is all the conversions between TimeSpan, DateTime...
user avatar
  • 8,402
8 votes
Accepted

VBuzz all fizzed up

Things I like: You defined the requirements correctly. Module was probably the right call. You used index instead of i for ...
user avatar
  • 30.7k
8 votes

Security issues in a SQL query and possible function?

You should not hard code queries into your VB code if you can help it. if you were using SQL Server I would say that you use Stored Procedures on the database instead of hard coded queries. by ...
user avatar
  • 28.5k
8 votes
Accepted

Security issues in a SQL query and possible function?

Make your code DRY (don't repeat yourself). Extract out your whole code of data retrieving to helper class CommandBehavior.CloseConnection will avoid closing the ...
user avatar
  • 2,638
8 votes

Using TryXXX pattern to avoid exceptions

I was going to edit my first answer, but as I wrote the example code I wanted to show, and refactored, and refactored again, ...the result went so far away from the original code that I thought it ...
user avatar
8 votes
Accepted

Best way to get the list of XML files

Option Strict You should always set Option Strict = On. Short circuit evaluation You should use the AndAlso operator instead of the ...
user avatar
  • 50k
8 votes

Autocompleting locations

Your comments should actually give you a hint. ' Getting data from DB: ' ... ' Populate retValue list with project names: These sound like the beginnings of good ...
user avatar
  • 30.7k
8 votes

Making error messages more efficient

So, you have a couple of issues here. First, your question... What I've done in VB6 (which your question was originally tagged as) is create a module that is responsible for reporting errors and ...
user avatar
  • 30.7k
8 votes

Rendering an HTML form based on a specification in a string

Before we start, take a look at this comment of yours. It's a prime example of why you shouldn't always trust the comments. ...
user avatar
8 votes
Accepted

Get list from database in 3 layer model

Well, you were right to think you are wrong. We shouldn't need to instantiate an object with an empty constructor to something like this. This is exactly what the ...
user avatar
  • 25.2k
8 votes

Give me thy name, I'll invoke thee

LINQ has two syntaxes to offer. You've used the method syntax, which I find very neat and useful, but for simpler queries I find the query syntax looks much less bulky in VB.NET: ...
user avatar
8 votes
Accepted

ROT13 encoder/decoder

The number one problem here is that you concatenate translated letters on to your string one at a time. Since strings are immutable in .NET (and most right thinking languages), this means for the ...
user avatar
  • 1,350

Only top scored, non community-wiki answers of a minimum length are eligible