21
votes
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 ...
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 ...
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:
...
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 ...
11
votes
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 ...
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 ...
11
votes
Accepted
Data Access Layer code for MSSQL Databases
This whole function needs a little bit of work:
...
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
...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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.
...
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 ...
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:
...
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 ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
vb.net × 345.net × 72
performance × 50
asp.net × 29
beginner × 24
object-oriented × 21
sql × 21
strings × 15
design-patterns × 15
c# × 13
cryptography × 10
excel × 9
linq × 9
array × 8
sql-server × 8
xml × 8
winforms × 8
algorithm × 7
multithreading × 7
mysql × 7
security × 7
datetime × 6
unit-testing × 6
regex × 6
file × 6