Wednesday, January 18, 2006
I was curious if anyone knew if Visual Studio 2005 had the capability to highlight or color "User Types" (i.e. classes you write yourself) while coding in Visual Basic. I know that C# has this functionality built in, but it doesn't seem like VB pays any heed to those settings. Here's a screenshot of the specific setting in Visual Studio:



If anyone knows anything about getting that working for VB, I'd appreciate it.

posted on Wednesday, January 18, 2006 1:04:46 PM (Central Standard Time, UTC-06:00)  #    Comments [0]
 Friday, January 13, 2006

Do you like C-based languages like C, C++, Java, and C#? Or do you like BASIC instead? It doesn't matter what your answer is, though, because the two links below are hilarious either way.

History of the BASIC family of languages
History of the C family of languages

(via Rockford Lhotka)

posted on Friday, January 13, 2006 2:54:49 PM (Central Standard Time, UTC-06:00)  #    Comments [0]

Continuing on my thoughts from yesterday regarding Windows Forms validation, I first began using Michael Weinhardt's validation library on MSDN after doing a project conversion from 1.1 to 2.0, but there were a few things that I personally wanted to do that weren't currently supported, like validation on controls like the DateTimePicker. It would have been quite easy to add support, but I began developing a picture in my mind of a slightly different approach to validation. His solution was very designer oriented, but I wanted a more code-centric approach.

What I came up with was basically a GroupValidator class that took a control and a delegate to a provided validation function. The class took care of calling the validation function by hooking into the Validating event and then setting the appropriate error message. It added the control and delegate to a collection which could then be looped through so that you could check to see if the entire group was valid. It is pretty basic, but it works quite well so far. I'd like to expand it a little bit to add more automation, but it gets the job done right now.

Here's an example of usage:

Public Class Form1

    Private _validator As New GroupValidator()

 

    Public Sub New()

        ' This call is required by the Windows Form Designer.

        InitializeComponent()

 

        ' Add any initialization after the InitializeComponent() call.

        _validator.AddControl(Me.TextBox1, _

            AddressOf IsTextValid, "Text not valid")

        _validator.AddControl(Me.TextBox2, _

            AddressOf IsTextValid, "Test not valid2")

        _validator.AddControl(Me.TextBox3, _

            AddressOf IsTextValid, "Enter something")

        _validator.AddControl(Me.TextBox4, _

            AddressOf IsTextValid, "Please")

    End Sub

 

    Private Function IsTextValid(ByVal c As Control) As Boolean

        If c.Text.Length > 0 Then

            Return True

        Else

            Return False

        End If

    End Function

 

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        MessageBox.Show(_validator.IsValid.ToString)

    End Sub

End Class

It is pretty simple as you can see. If you're interested in the code, drop a line and I'll email it or post it.

posted on Friday, January 13, 2006 8:53:27 AM (Central Standard Time, UTC-06:00)  #    Comments [0]
 Thursday, January 12, 2006

I've been doing some research on best practices for validation in Windows Forms, and I came across a nice set of MSDN articles by Michael Weinhardt where he shows how to create a validation framework that is very similar to the validators found in ASP.NET (i.e. required field validator, regular expression validator, etc). It includes container and form validators that basically manage the control validators already on the form. The link to the articles is to the third article in the series, but the download contains all of the source. His code was apparently incorporated into the Genghis framework as well.

I'm interested in something similar for 2.0, but I haven't found anything. I did see an older post from Chris Sells about moving Genghis over to 2.0, but I haven't seen any updates on that. I'm considering doing it myself, but if anyone has any better ideas, I'm open.

posted on Thursday, January 12, 2006 2:07:18 PM (Central Standard Time, UTC-06:00)  #    Comments [0]

After some severe frustration research, I was able to discover how to repro the crash in Visual Studio 2005 yesterday. It is actually quite simple to do. You need a new VB.NET project and two With statements, one nested within the other. That's it. Then you click on the second With object.

Here, I'll show you how!

Public Class Form1

    Public Shared Sub Main()

        Application.Run(New Form1)

    End Sub

 

    Public Sub New()

        ' This call is required by the Windows Form Designer.

        InitializeComponent()

 

        ' Add any initialization after the InitializeComponent() call.

        Dim p As New Person()

        With p

            ' CRASHHERE: If you want to crash, take your mouse and

            ' click inside .StreetAddress.... BOOM!

            With .StreetAddress

                .Street = "123 BOOM"

            End With

        End With

    End Sub

 

    Public Class Person

        Private _streetAddress As New Address

        Public ReadOnly Property StreetAddress() As Address

            Get

                Return _streetAddress

            End Get

        End Property

    End Class

 

    Public Class Address

        Private _street As String

        Public Property Street() As String

            Get

                Return _street

            End Get

            Set(ByVal value As String)

                _street = value

            End Set

        End Property

    End Class

End Class

 

There, that was easy, huh? (In case you're not seeing it, look for the CRASHHERE note.)

Kids, don't try this at home.

Chances are, it will work for you anyway. I just checked with one of my co-workers and it works just fine for him. Great.

posted on Thursday, January 12, 2006 8:07:54 AM (Central Standard Time, UTC-06:00)  #    Comments [0]
 Wednesday, January 11, 2006

5+ crashes in a row is a little much.

And I wasn't even in the designer. And yes, I rebooted. It still happened.

I don't know exactly what I did to fix it, though. Let's just say heavy use of the save button and having another instance of devenv up and attached to the other process. Just in case I needed to copy and paste a call stack somewhere. Of course, that's when it began working.

Oh well.

NOTE: Don't take this the wrong way. I still love VS2005 as an IDE. However, it still has quite a few issues. The most annoying of which is the flickering while in the designer. And no, I never got that one up in the debugger either.

UPDATE: For more information on this, see my new post here.

posted on Wednesday, January 11, 2006 2:50:25 PM (Central Standard Time, UTC-06:00)  #    Comments [0]
 Monday, January 09, 2006

How about FOUR?!?

Dell just announced at CES 2006 their XPS Renegade gaming system that utilizes FOUR GPUs with a 4.26 GHz processor. Here is the link at IGN and here is the direct link to Dell's Flash site.

That's just insane.

And for just over $2,000, you can purchase their 30-inch monitor, too.

Can we say overkill?

posted on Monday, January 09, 2006 1:06:01 PM (Central Standard Time, UTC-06:00)  #    Comments [0]
 Saturday, January 07, 2006

This may seem a little weird, but I was checking my webstats for the blog and I saw that one of the Googlebots came across it. That prompted curiosity on my part to see if I could find this page by searching for it. I didn't find my site yet, but I sure found some other stuff.

I got into the web around 1996 or 1997, right when the internet was becoming more mainstream. I remember using Netscape Composer to build websites back then (I wasn't cool enough to be one of those guys who coded their entire site in Notepad) and the coolest webpages had billions of animated GIFs, a tiled background, and a guestbook. Most of the search results I found were my signing of other people's guestbooks in hopes of having them come and sign MY guestbook. 

The other cool thing to do was to display all of the "awards" that your site had won. They were basically just cooked up images that ANYONE could create. All anyone had to do to get the award was ask for it and then link back to your site. It was all pretty ridiculous, but then again, no one knew better. I actually found one of my awards still being displayed on some site that I have no recollection of ever visiting.

Wow, memories.

posted on Saturday, January 07, 2006 2:17:33 PM (Central Standard Time, UTC-06:00)  #    Comments [0]
 Thursday, January 05, 2006

My post earlier today referred to the FileHelpers library by Marcos Meli.

Wow, do I wish I had known about this earlier. This thing is great! With a few easy attributes, you can use a business object as a layout for fixed-length files! Okay, I guess an example would help. Here's some VB code I whipped up to test this library out.

Imports FileHelpers

Public Class MainForm
    Private Sub MainForm_Load(ByVal sender As Object, _
        ByVal e As System.EventArgs) Handles Me.Load

        Dim engine As New FileHelperEngine(GetType(Record))

        Dim records() As Record = _
            DirectCast(engine.ReadString("123456789  2005-01-01"), _
            Record())

        Debugger.Break()

        Dim res As String = engine.WriteString(records)

        Debugger.Break()
    End Sub
End
Class

<FixedLengthRecord()> _
Public
Class Record
    <FieldFixedLength(11)> _
    Public BillNumber As String

    <FieldFixedLength(10), _
    FieldConverter(ConverterKind.Date, "yyyy-MM-dd")> _
    Public BillDate As DateTime
End
Class

At each Debugger.Break line, I checked my values and this thing is great. records(0).BillNumber is "123456789  " and records(0).BillDate is a converted DateTime set to 1/1/2005.

If you deal with fixed-length or delimited files on a regular basis, this library might be a great option for you.

Thanks Marcos!

UPDATE: Version 1.3.1 was released recently, so I have updated my example code to use the new ReadString and WriteString methods.

posted on Thursday, January 05, 2006 1:53:42 PM (Central Standard Time, UTC-06:00)  #    Comments [1]

By way of Larkware, I came across the FileHelpers library written by Marcos Meli. It looks like a great solution for dealing with delimited or fixed length file formats. The majority of the output formats from our backend systems at work are fixed length file formats, which can be a pain to parse. I had actually written a library to parse them and reference portions of each line by name (sort of a named index to portions of a line), but this looks like a much cleaner approach. I'll dig into this some more and post my thoughts on it.

posted on Thursday, January 05, 2006 1:21:07 PM (Central Standard Time, UTC-06:00)  #    Comments [0]
 Wednesday, January 04, 2006

Over a year ago, I built a new PC from the ground up. This wasn't my first PC to build mind you. I hand-picked all of the parts and had a great time putting it together. If you've ever built a PC, you know the feeling of hitting the power button after hooking the final jumpers and hearing that familiar whirr as the PC boots up. Boy, is it a scare when it doesn't do that! That's what happened with this PC... absolutely nothing. Long story short, I got the PC to come on finally, but everytime I shut it down, it wouldn't come back on without my resetting the CMOS by using a jumper on the motherboard. I tried replacing the CMOS battery, changing out the memory... everything. I finally found some people online in a hardware forum with a similar problem. Their solution? RMA. *sigh* What was MY solution? Get a Dell. Okay, okay, I'll admit it. I chickened out. I just didn't want to get burned again. I'm still using that Dell, too.

Flash forward to the present. I wanted to build a PC for my wife and I still had that motherboard sitting around. I ended up RMA'ing it and I got a replacement back. I hooked it all up a few nights ago and, miraculously, it worked! I had a few strange lock-ups, but they seemed to stop. Tonight, it won't turn on. I took the case off and reset the CMOS to see if anything would happen. Something did happen, but only for a second. I heard the whirr for about a second and then silence. I would guess a short, but I don't know. Building a PC is a lot of fun, but it can be great source of frustration when it doesn't work.

My recommendation for building PC's (ha, like you'll listen to me now) is do a Google search on some of the hardware you're interested in, but put words in there like "problem" or "this piece of crap won't work" or something. If you find a lot of results, check them. It can save you some stress later on.

posted on Wednesday, January 04, 2006 10:06:58 PM (Central Standard Time, UTC-06:00)  #    Comments [0]

I ran into that error today while attempting to install Infragistics NetAdvantage 2005. I'm not exactly sure about why the error occurred, but I was able to find a fix here (via this MSDN forum thread). Some of the other solutions appear to be reinstalling VS2005, but luckily, the registry fixes from Chetan's blog worked fine.

posted on Wednesday, January 04, 2006 4:47:57 PM (Central Standard Time, UTC-06:00)  #    Comments [0]

Has anyone noticed a new menu item under the Build menu in Visual Studio 2005? There is a Clean Solution item that will remove all of the compiled binaries that live under your bin folder. It is relatively similar to Clean Sources Plus, except that it keeps the folders.

Note: I'm not sure if it shows up in every VS configuration. I'm using the default view (see Tools -> Import and Export Settings).

posted on Wednesday, January 04, 2006 1:11:43 PM (Central Standard Time, UTC-06:00)  #    Comments [1]