.NET,  Coding,  Stemspo

Coding Progress: Refactoring an add-in with .NET with VB.net

This is my second blog entry and the purpose with this blog to begin with was to keep track of my coding progress. Read my first blog entry Setting up a new female developer blog.

I’m currently refactoring an add-in to a GIS program. Refactoring it from VBA to VB.NET. It’s a fun project at work, but oh so challenging! I’m fairly new to VB.NET, as I’ve fiddled with PHP and a bit C#. Another challenge was also that I never worked with the GIS program that I’m refactoring the add-in to. However, I love me a challenge and coding is something I think is super exciting, so I took the opportunity to take on this project when my former colleague was not able to.

I have learned so much in such a short time and continue to do so. Improving my skills in something I enjoy and something very important and with this project I can do just so!

The three challenges I had and the solutions were:
1. Defining a double and convert it to a double into the recordset.
2. Defining a string into a string in the recordset.
3. Defining a datetime into a string in the recordset.

The first one was fairly easy which I was able to make on my own. The second and third ones were a bit more challenging.

I tried various things, according to tutorials. I even went to StackOverflow and wrote my first question. The community at StackOverflow was kind enough to help out, but one gave me a question to my question, which I asked myself when I started dabbling with refactoring the sql connection. However, the client wants what the client wants – in the end they are the one paying and will be working with it.

So going back and forth with the challenges, taking up several hours. Loosing hope and loosing confidence almost. I then asked a coworker who’s experienced in VB.NET and luckily together we were able to find the solution to my challenges.

Below is a snippet and parts of the codes which I was having challenges with. Note that it’s note the entire code and I’ve left out a few things. However, these are the things that made my code work properly. Can you imagine, so few lines of code giving you such a big headache? 🙂


Dim sNr As String
Dim area_polygon As Double
Dim TimeOut As DateTime
sNr = Convert.ToString(AdoRS("nr").Value)
area_db = CDbl(AdoRS("area_m2").Value)
sTimeOut = Convert.ToString(AdoRS("timeout").Value)
strSqlUpdateArea = "UPDATE CUSTOMERAREA Set Area_m2='" & area_polygon & "' WHERE Nr=" & sNr
AdoConn.Execute(strSqlUpdateArea)

Leave a Reply

Your email address will not be published. Required fields are marked *