by
Your DisplayName here! via
David McCarter
on
6/19/2009 7:03:36 PM
Entity Framework samples have not been released in VB.NET! Check out the blog link below.
Full Blog Entry: http://blogs.msdn.com/vbteam/archive/2009/06/18/vb-entity-framework-samples-now-available-lisa-feigenbaum.aspx
|
|
by
Your DisplayName here! via
David McCarter
on
6/9/2009 2:17:44 AM
I hope everyone in Arizona and southern California is planning to attend this years Desert
Code Camp on 6/13 and SoCal Code Camp in
San Diego on 6/27 - 6/28. It's always a great time and lots of free training! I
will also be selling a limited number of my latest book " David
McCarter's .NET Coding Standards " at my sessions for $12, cheaper than the web
site (no tax and shipping), please bring exact change or check.
I will be presenting the following sessions and I hope you will atten ... [ read more ]
|
|
by
Your DisplayName here! via
David McCarter
on
4/13/2009 8:33:18 PM
If you need to serialize and deserialize your objects and persist them
to disk, the the code below is an easy way to accomplish this. The
GetObjectTypes function
correctly detects types so that the serializer will do it's job correctly. Without
this you could run into problems (as I did).
VB
''' <summary>
''' Deserializes from XML file.
''' </summary>
''' <type ... [ read more ]
|
|
by
Your DisplayName here! via
David McCarter
on
3/18/2009 10:48:21 PM
If you are stuck using VB6 and .NET check out the site below.
http://msdn.microsoft.com/en-ca/vbrun/ms788241.aspx
|
|
by
Your DisplayName here! via
David McCarter
on
3/2/2009 6:51:05 AM
If you live in the San Diego area, dotNetDave (a.k.a. David McCarter) will be teaching a 6 week Fundamentals
of the .NET Framework course at the University of California, San Diego Extension
beginning on Wednesday 4/1/2008 from 5:30pm to 9:15pm. For more information and to
enroll, please click
here .
|
|
by
Your DisplayName here! via
David McCarter
on
12/22/2008 10:27:30 PM
As most of you might know (I hope) it is unwise to call methods on a Control from
a non-UI thread. This can cause all sorts of issues. Actually, I think in most cases
.NET will throw and Exception. If you need to set a property on a Control this is
how you would properly do it.
VB.NET
Delegate Sub SetPropertyValueDelegate( ByVal obj As Object , ByVal val As Object , ByVal index As Object ())
Public Sub SetControlPropert ... [ read more ]
|
|
by
Your DisplayName here! via
David McCarter
on
10/29/2008 9:01:30 PM
Learn about the future of VB.NET!
http://code.msdn.microsoft.com/vbfuture
Here is some of what is new:
* sub lambdas, and multiline
sub/function lambdas
* sub lambdas, and multiline sub/function lambdas
* AsParallel. (well, this was a plinq feature rather than a VB feature, but cool as
heck)
* DLR interop: invoke DLR methods from VB; create dynamic objects from VB; pass .net
objects to DLR code; pass DLR objects to VB code. Note: unfortunately, this feature
wasn’t rea ... [ read more ]
|
|
by
Your DisplayName here! via
David McCarter
on
10/14/2008 7:26:40 PM
If you came to my talk at the OC .NET User group meeting today, below is a link to
the presentation. Enjoy!
Why You Need .NET Coding Standards (2008)
Why
You Need .NET Coding Standards-2008.pdf (941.06 KB)
Link to my book: http://www.cafepress.com/geekmusicart.165478704
|
|
by
Your DisplayName here! via
David McCarter
on
9/23/2008 10:59:47 PM
If you are interested in using LINQ to read Xml instead of the older way of the XmlDocument
and SelectNodes, the code below is a pretty good example. The code takes in the ISO
standard file for country names and codes (see sample below) and turn it into a list
of Country objects for use in an application including ComboBoxes.
<? xml version = " 1.0 " encoding = " ISO-8859-1 " standalone = " yes " ?>
< ISO_3166-1_List_en xml:lang = " en " >
... [ read more ]
|
|
by
Your DisplayName here! via
David McCarter
on
9/2/2008 7:05:30 PM
If you are coming to the San Diego .NET Developers Group meeting tonight I hope you
will be their early for my talk titled " What’s New In VS 2008 SP1 ".
Lots of new additions to this SP, not just bug fixes. Below is a link to the presentation.
VS2008Sp1.pdf (715.88
KB)
|
by
Your DisplayName here! via
David McCarter
on
9/2/2008 6:36:07 PM
If you live in the San Diego area, dotNetDave (a.k.a. David McCarter) will be teaching a 6 week Fundamentals
of the .NET Framework course at the University of California, San Diego Extension
beginning on Thursday 9/24/2008 from 5:30pm to 9:15pm. For more information and to
enroll, please click
here .
|
|
by
Your DisplayName here! via
David McCarter
on
9/1/2008 6:47:22 PM
I hope everyone in California
is planning to attend this years Central Coast Code Camp up in San Luis Obispo
on 9/27 - 6/28. It's always a great time and lots of free training! I will also be
selling a limited number of my latest book " David
McCarter's .NET Coding Standards " at my sessions for $11, cheaper than the web
site (no tax and shipping), please bring exact change.
I will be presenting the following sessions and I hope you will attend.
dotNetDave's
.NET Utility Assemb ... [ read more ]
|
|
by
Your DisplayName here! via
David McCarter
on
8/15/2008 8:20:43 PM
Do you want to retrieve all the Exceptions, including the inner Exceptions when an
Exception is thrown for logging purposes? Since they are not enumerable, I wrote a
block of recursive code below that will do the trick.
1 Function RetrieveAllExceptions( ByVal ex As Exception) As ObjectModel.ReadOnlyCollection( Of Exception)
2 Dim exceptions As New Generic.List( Of Exception)
  ... [ read more ]
|
|
by
Your DisplayName here! via
David McCarter
on
8/8/2008 4:00:46 PM
The link below takes you to the Microsoft Express products like Visual Basic Express
2008 and SQL Server Express 2008.
http://www.microsoft.com/express/
|
|
by
Your DisplayName here! via
David McCarter
on
7/16/2008 11:35:43 PM
Getting command line parameters or seeing if they are present is not as easy as you
would think. I whipped up some code to make this flexible and easy.
Private Const ParameterPrefix As Char = "/"c
Private Function GetCommandLineArgument(ByVal parameter As String) As
String
Dim paramValue = String.Empty
For Each tempValue As String In System.Environment ... [ read more ]
|
|
by
Your DisplayName here! via
David McCarter
on
7/15/2008 9:32:56 PM
Here is some easy, generic code to serialize your objects to and from JSON:
Public Shared Function JsonEncode(ByVal input As Object) As String
Dim serilizer = New DataContractJsonSerializer(input.GetType)
Using ms = New MemoryStream()
serilizer.WriteObject(ms, input)
Return Encoding.Default.GetString(ms.ToArray())
End Using
End Function
Public Shared Function JsonDecode(Of T)(ByVal input As String) As T
Using ms = New MemoryStream(Encoding.Unicode.GetBytes(in ... [ read more ]
|
|
by
Your DisplayName here! via
David McCarter
on
6/30/2008 9:33:50 PM
I recently started a new job that uses C#. I have been trying for two frickin hours
to get Trace Listeners working in an application here with no luck at all. So to test
that I have the web.config setup correctly, I added the following:
var log = new Microsoft.VisualBasic.Logging.Log();
log.WriteEntry("VB Log");
Bam, it works! Dang I LOVE VB.NET! Now I'm going to go ask my boss if I can use the
VisualBasic.Logging class in our C# application ;-)
David McCarter
|
|
by
Your DisplayName here! via
David McCarter
on
6/1/2008 3:55:28 PM
I hope everyone in southern
California is planning to attend this years SoCal
Code Camp up at University California San Diego on 6/28 - 6/29. It's always a
great time and lots of free training! I will also be selling a limited number of my
latest book " David McCarter's
.NET Coding Standards " at my sessions for $11, cheaper than the web site (no tax
and shipping), please bring exact change.
I will be presenting the following sessions and I hope you will attend.
dotNetDave's
.N ... [ read more ]
|
|
by
Your DisplayName here! via
David McCarter
on
4/14/2008 4:34:27 PM
If you live in the San Diego area, dotNetDave (a.k.a. David McCarter) will be teaching a 6 week Fundamentals
of the .NET Framework course at the University of California, San Diego Extension
beginning on Thursday 5/14/2008 from 5:30pm to 10:00pm. For more information and to
enroll, please click
here .
|
|
by
Your DisplayName here! via
David McCarter
on
2/27/2008 8:00:52 PM
Today I released the first public version of my dotNetTips.com Utility assembly. This
is an open source .NET 2.0 utility assembly that contains useful common code
that anyone can use in just about any project. Helper classes include Active Directory,
Validation, IIS, File IO, Security, Computer Info, Web, XML and more. Other classes
include a better TextBox and ComboBox, sending e-mail, encryption and more.
To download go to:
http://www.codeplex.com/dotNetTipsUtility
|
|
by
Your DisplayName here! via
David McCarter
on
1/19/2008 4:25:26 AM
I hope everyone in southern
California is planning to attend this years SoCal
Code Camp up at Cal State Fullerton on 1/26 -1/27. It's always a great time and
lots of free training! My fav southern California band Killola will
be playing again at the Geek dinner so make sure you arrive early on Saturday to grab
one of the limited number of tickets available.
I will be doing the following sessions and I hope you will attend.
dotNetDave's .NET Utility Assembly (My First CodeP ... [ read more ]
|
|
by
Your DisplayName here! via
David McCarter
on
1/2/2008 9:01:35 PM
Often, it's a good idea to make sure the user trying to access the file has permissions
to it before performing an operation like read, write or delete. Below is code that
makes this pretty easy.
Sub DemandFileReadPermission( ByVal fileName As String )
If System.IO.File.Exists(fileName) Then
Dim filePermission As New System.Security.Permissions.FileIOPermission(System.Security.Permissions.FileIOPermissionAcc ... [ read more ]
|
|
by
Your DisplayName here! via
David McCarter
on
1/1/2008 8:14:18 PM
If
you live in the San Diego area, dotNetDave (a.k.a. David McCarter) will be teaching
a 6 week Building Rich & Interactive Web Applications with ASP.NET AJAX course
at the University of California, San Diego Extension beginning on Thursday 2/21/2008
from 5:30pm to 10:00pm. For more information and to enroll, please click
here .
|
|
by
Your DisplayName here! via
David McCarter
on
12/16/2007 12:15:16 AM
If you need to convert a Bitmap to an Byte array, here is how you do it.
Public Shared Function ConvertToByteArray( ByVal value As Bitmap) As Byte ()
Dim bitmapBytes As Byte ()
Using stream As New System.IO.MemoryStream
value.Save(stream, value.RawFormat)
bitmapBytes = stream.ToArray
... [ read more ]
|
|
by
Your DisplayName here! via
David McCarter
on
12/15/2007 12:08:22 AM
There are many times when I need to convert an array to a delimited string. Here is
an easy way to do it using generics in .NET 2.0.
Public Shared Function ConvertArrayToString( Of arrayType As {IEnumerable})( ByVal array As arrayType(), ByVal separator As Char ) As String
If Not IsValidArray(array) Then
Throw New ArgumentNullException( "array" )
End I ... [ read more ]
|
|
by
Your DisplayName here! via
David McCarter
on
12/14/2007 8:44:28 PM
.NET still does not expose the drive serial number via the framework. For that you
will need to use WMI. Here is the code.
Shared Function GetDriveSerialNumber( ByVal drive As String ) As String
Dim driveSerial As String = String .Empty
'No matter what is sent in, get just the
drive letter
Dim driveFixed As String =
System.IO.Path.GetPathRoot(drive)
driveFixed = Replace(driveFi ... [ read more ]
|
by
Your DisplayName here! via
David McCarter
on
12/14/2007 8:33:51 PM
Here is some simple code to validate that an array is valid. Before trying to use
an array, you should always validate it with this code first.
Public Shared Function IsValidArray( ByVal array As Array) As Boolean
Dim valid As Boolean = False
If array Is Nothing Then
Throw New ArgumentNullException( "array" )
End If
... [ read more ]
|
|
by
Your DisplayName here! via
David McCarter
on
12/10/2007 7:07:53 PM
When data binding to a DropDownList control in ASP.NET, there are in many cases when
you want the first selection of the control to be blank or say something like "<please
select value>". In part
one of this tip (back in 2003), I wrote that you could just add an empty row to
the DataSet. In VS 2005 and the new way of data binding that I usually do to web services,
this is more difficult. So here is another solution just using code in your ASP.NET
code.
Protected Sub DropDownLi ... [ read more ]
|
|
by
Your DisplayName here! via
David McCarter
on
11/15/2007 11:01:35 PM
Visual Basic Beer? Well not really, but we can only hope. Don't look for this in your
local store unless you are in Australia.
|
|
by
Your DisplayName here! via
David McCarter
on
9/20/2007 7:12:56 PM
If you need to convert RTF to text, here is a simple way of doing it:
Public Shared Function ConvertRtfToText(ByVal input As String) As String
Dim returnValue As String = String.Empty
Using converter As New System.Windows.Forms.RichTextBox()
converter.Rtf = input
returnValue = converter.Text
&nb ... [ read more ]
|
|
by
Your DisplayName here! via
David McCarter
on
9/5/2007 3:50:17 PM
The
second edition of this book (formerly VSDN Tips & Tricks .NET Coding Standards), is
a consolidation of many of the .NET coding standards available today in one easy to
read and understand book. It will guide any level of programmer or development department
to greater productivity by providing the tools needed to write consistent, maintainable
code.
The core of the book focuses on naming standards, how to order elements in classes,
declaring methods, properties and much, m ... [ read more ]
|
|
by
Your DisplayName here! via
David McCarter
on
8/13/2007 9:56:11 PM
Line and Shape controls, PrintForm component, and Printer Compatibility Library
Microsoft Visual Basic 2005 Power Packs 2.0 includes a new set of Line and Shape
controls and updated versions of the two previously released Visual Basic 2005 Power
Packs, the PrintForm Component and the Printer Compatibility Library. All three are
now included in a single assembly making them even easier to use and redistribute
with your application.
http://www.microsoft.com/downloads/details.aspx ... [ read more ]
|
|
by
Your DisplayName here! via
David McCarter
on
8/9/2007 7:03:55 PM
San Luis Obispo will be holding a code camp on September 22nd, 2007. I will be attending
and presenting. For more info go to: http://www.centralcoastcodecamp.com/
Articles/News:
http://www.sanluisobispo.com/business/story/134783.html
> >
Code
Camp on KCOY
My sessions will be:
Building Rich & Interactive Web Applications with ASP.NET AJAX
Presentation: AjaxSession091807.zip
(875.6 KB)
Code Example: AjaxExample.zip
(703.12 KB)
Why You Need .NET ... [ read more ]
|
by
Your DisplayName here! via
David McCarter
on
8/9/2007 7:01:27 PM
Phoenix will be holding another code camp on September 15th, 2007. I will be attending
and presenting. For more info go to: http://desertcodecamp.com/
My sessions will be:
Building Rich & Interactive Web Applications with ASP.NET AJAX
Presentation: AjaxSession.zip
(1023.53 KB)
Code Example: AjaxExample.zip
(703.12 KB)
Why You Need .NET Coding Standards
Presentation: StandardsSession.zip
(1.6 MB)
|
|
by
Your DisplayName here! via
David McCarter
on
3/24/2007 6:32:27 PM
I came up with some generic methods to do the job:
Public Shared Function DeserializeXMLToObject(ByVal input As String, ByVal type As System.Type) As Object
Dim result As Object = Nothing
Dim serializer As New XmlSerializer(type)
Try
result = serializer.Deserialize(New XmlTextReader(New StringReader(input)))
Catch ex As Exception
Debug.WriteLine(ex.Message)
End Try
Return result
End Function
... [ read more ]
|
|
by
Your DisplayName here! via
David McCarter
on
10/6/2006 7:04:49 AM
To download go to: http://go.microsoft.com/?linkid=5559918
|
|
by
Your DisplayName here! via
David McCarter
on
3/26/2005 11:27:57 PM
Great article on generating docs for your VB.NET Application:
http://msdn2.microsoft.com/en-us/library/Aa289191(VS.71).aspx
|
|
by
Your DisplayName here! via
David McCarter
on
6/22/2004 8:58:16 AM
The Power Pack controls consist of:
BlendPanel. This provides a background for a form where the color fades from one shade
to another.
UtilityToolbar. This is a toolbar whose look and feel is similar to the Internet Explorer
toolbar.
ImageButton. This is a button that displays a graphic over a transparent background.
NotificationWindow. This displays text and graphics in a pop-up window (commonly known
as "toast").
TaskPane. This is a container that provides collapsible fram ... [ read more ]
|
|
by
via
David McCarter
on
5/14/2004 10:39:24 PM
http://msdn.microsoft.com/vbasic/atthemovies/
|
|
by
via
David McCarter
on
10/9/2003 7:50:23 AM
http://msdn.microsoft.com/vbasic/vbrkit/default.aspx
|
|
by
Your DisplayName here! via
David McCarter
on
9/9/2003 8:15:46 AM
Just use the code below. I'm sure you will want to replace the hard-coded values with
parameters from a method.
Dim mailProcess As New Process()
Dim processInfo As New System.Diagnostics.ProcessStartInfo()
processInfo.FileName = " mailto:someone@someone.com ?"
_
& " cc=someoneelse@someone.com &"
_
&n ... [ read more ]
|
|
by
Your DisplayName here! via
David McCarter
on
8/26/2003 9:35:39 AM
It’s was told to me that this can never be shown to the client and further more the
number can never be rounded (anyone ever see Office Space… sound familiar?).
So I went searching on how to do this in .NET. After many, many hours of searching
and testing, I could not find any way in .NET to do this. Every function I found would
always round the number! I found myself wishing for just a way to flip a switch to
tell .NET to stop doing that. So I finally gave up and came up with a short func ... [ read more ]
|
|
by
Your DisplayName here! via
David McCarter
on
8/15/2003 8:50:01 AM
The function below returns the appliction path for an appliction in the Compact Framework.
Shared Function GetAppPath() As String
Dim mstrPath As String
mstrPath = _
System.IO.Path.GetDirectoryName
(System.Reflection.Assembly.GetExecutingAssembly().GetModules
(0).FullyQualifiedName)
If Right(mstrPath, 1) <> "\" Then
mstrPath += "\"
End If
Return mstrPath
End Function
Tip Submitted By: David McCarter & Marquis Howard
... [ read more ]
|
by
Your DisplayName here! via
David McCarter
on
8/15/2003 8:44:48 AM
So I created the nifty little Function below:
Private Function GetWebFormValue(ByRef WebForm As System.Collections.Specialized.NameValueCollection, _
ByVal ControlName As String) As String
Try
Return WebForm(ControlName).ToString
Catch
&nb ... [ read more ]
|
by
Your DisplayName here! via
David McCarter
on
8/15/2003 8:41:17 AM
Below are some converted VB6 methods that do common database connection tasked. The
first one (CheckSQLConnection) checks to make sure that a connection can be made to
the database. This could be used at the beginning of your application or web application
to make sure that the database is up. If it's not, doubt if there is much need in
continuing.
The next method (CloseSQLConnection), closes a SQLConnection object if it is open.
NEVER assume that the connection was successfully opened du ... [ read more ]
|
by
via
David McCarter
on
8/15/2003 8:38:35 AM
Okay, I need to give you some history of .NET... at first, by default, Options Strict
was turned on. This is a good thing! It makes for better bug free code. Many of us
have been waiting for this for a long time. But, some of the big-wigs in the VB world
started crying?!?! Why...
because they said that this would hamper their efforts to migrate VB6 code to VB.NET.
Ha! Migrating code is a pipe dream and should be avoided at all costs. For some STUPID
reason Microsoft actually listened to ... [ read more ]
|
by
via
David McCarter
on
8/15/2003 8:32:14 AM
When setting a string object to an empty string, I did a test and I found that doing
this:
Dim ContentFieldName As String = String.Empty
Is slightly faster than doing this:
Dim ContentFieldName As String = ""
Your results my vary
Tip Submitted By: David McCarter
|
by
via
David McCarter
on
8/15/2003 8:30:33 AM
Regular
Expressions in .NET By Darren Neimke
|
by
via
David McCarter
on
8/15/2003 8:28:44 AM
Using VB6, it took a lot of code to read values from the Registration Database. Well,
not anymore with with VB.NET! Take a look at the code below.
Imports Microsoft.Win32
Function GetDBConnect() As String
Dim pobjRegKey As RegistryKey
Dim pstrValue As String
pobjRegKey = _
Registry.LocalMachine.OpenSubKey("SYSTEM\CurrentControlSet\Services\MyService\Parameters",
False)
If Not IsNothing(pobjRegKey) Then
pstrValue = pobjRegKey.GetValue("DBCon ... [ read more ]
|
|
by
via
David McCarter
on
8/13/2003 10:23:54 AM
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcn7/html/vaconVBNamingRules.asp
|
|