VB.NET 2005 DataGridView to Excel

Copying data to excel is usually done by dumping the records into a comma-delimited file. Works great, right? It only works great if you have simple apples and oranges types of data. If you have any fields with leading zeros, like a purchase order number, then excel drops the leading zeros.

Enter XML.

Microsoft Excel easily reads xml files (stored as .xls) and formats the fields based on the style tags in the style portion of the xml. This code takes the new DataGridView as is popular in vb.net 2005 and dumps the data into an xml file based on the data and column types and formats the data for you.

See the comments at
DataGridView to Excel for the vb.net version. Otherwise, the article code is in Csharp.

Comments

Treeview Images

The treeview control is daunting, no doubt about it. Images can be associated with each node but there is very little documentation on how to do that.

1. Add a treeview control on your vb.net form.
2. Add an imagelist to the form.
3. Populate the image list with three different images (preferably small icon files)
4. Click the treeview and view the treeview properties.
5. Select the dropdown box for ImageList and pick the imagelist you added (imagelist1)
6. Select the imageindex and imagekey and set both to o (zero). This will associate all treeview nodes with that image and play it before the node text.
7. Also note the property “SelectedImageIndex.” This is used for displaying different images based on whether or not the node is selected.

All is great, right? Wrong. Now it’s time to add nodes and child nodes. So how do you associate different icons with the nodes?

Dim NodeArray(0) As TreeNode
Dim FieldNode As New TreeNode("I am a child node", 2, 2)
FieldNode.Tag = "child"
FieldNode.SelectedImageIndex = 2
NodeArray(0) = FieldNode
Dim SegmentNode As New TreeNode("I am the parent node" , 1, 1, NodeArray)
SegmentNode.Tag = "parent"
SegmentNode.SelectedImageIndex = 1
Dim selectedTreeview As TreeView = CType(sender, TreeView)
Dim targetNode As TreeNode = selectedTreeview.SelectedNode
'this code inserts the node under a selected node or the root level if no node selected.
If targetNode Is Nothing Then
Me.Treeview1.Nodes.Add(SegmentNode)
end if

You add backwards. You build the child node as a node array and this gives access to the images and tag properties. then you associate that with a parent node and build that into an array as well. 1 and 2 are the image indeces. Then you add it as a node collection.

Comments

Look Backwards In .NET strings

This code example is so simple and easy.
Let’s say you have the string:
“The query has completed running : Status Successful”

How can you extract the status value of “Successful?”

Look backwards….

Dim int1 As Integer
Dim StatusString as String
Dim StatusActual as String
StatusString = "The query has completed running : Status Successful"
StatusString = StatusString.Trim 'just in case spaces at end.
int1 = InStrRev(StatusString, ” “)
‘you now have the location of the first space starting from the right side
StatusActual = StatusString.Substring(int1)
‘You now have the value of “Successful”

Comments

Microsoft Visual Studio Express Editions

I hesitate to say this…but I can’t resist…the Express versions of Microsoft Visual Studio ROCK! I’ve been a longtime user of visual basic 6.0 (vb6) and have a few years of vb.net 2003 under my belt. I previewed vb.net 2005 at many an MSDN event. However, the idea of chucking out at lot of money for 2005 just didn’t give me a good feeling. It’s the old idea of “this version works so why should I change.” Then it happened.

Time and time again I was finding sample code, on places such as www.codeproject.com, that were in vb.net 2005. Remembering Microsoft released the free & limited versions as Express editions, I thought “what the heck!”

The express editions have provided 99.5% of the functionality I needed. I even built a full functioning oracle query tool similar (yet better) to SQL Server’s Query Analyser and Oracle’s Sql Developer.

What about that 0.5%? So far, I’ve only found two issues. One might just be my oversite. I haven’t found away to colapse all code at the same time. I have to do that through clicking the [-] sign by each routine. The other is a Click-Once issue.

Click-Once deploys my application onto our network. Then anytime the users run the program, Click-Once looks for an update. The Click-Once configuration appears limited as upgrading. Currently, the users have to click a button to update the software. From what I’ve read, Click-Once offers an option so user interaction isn’t required. That option isn’t in the express version. I can live with that minor inconvenience.

Microsoft Visual Studio Express Editions of VB.NET and C# (CSharp) are by no means extremely-limited in functionality.

Comments

Marketing No More

Marketing is a fascinating topic and I loving talking about marketing. But for the sake of programmers, I’m switching the topic of this blog. Every day, I’m writing computer programs. Every day I find something new - even after 10 years in the field of programming. This blog will now post my daily bits of code snippets or new technics that make my job easier!

Comments

Morning Interviews

This morning I was interviewed for my college’s alumni publication. This was a great opportunity to pour my heart out about my work with x3church.com.

How Did It Go?
The last words I remember saying are “please make that sound better than I just said it.” I’m a morning person. I’m up at 6am if not earlier. Last night, I woke up every few hours. Was it nerves? Was it my wife “stealing the covers?” Probably both. The reporter did a great job as I sat there trying to formulate simple sentences and sip my coffee.

What Should I Have Done?
Scheduled the interview for a later time. No matter how tired I am in the morning, by the afternoon, I’m fully awake and thinking in complete sentences. I’m usually wide awake at 7am…but not today.

What You Should Do!

  • Schedule interviews or other important meetings around the portions of the day in which you are most productive. If you are a morning person, that’s usually from 2pm-4pm. If you are an evening person, it’s around 4pm-6pm.
  • Even if you are comfortable with a topic, take notes with you. You’d be surprised at how many things you can forget at a moments notice.
  • Got a big day ahead? Go to bed early. Even if you wake up a few times, you’ll bless those few extra hours of sleep.

P.S. If you live in Washington D.C. and are looking for a journalist, I know a college senior who wants to talk to you.

Comments

Scam A Friend?

The Nigerian email scam has been around for years. The idea is simple, the scammer provides a bogus money order, and you deposit it and then wire 90% of it back to them. The 10% is your gift for helping in the money exchange. The scam is the money order isn’t detected as bogus until after you wire the money - so YOU get well, up a creek without a paddle.

This scam has been around for so long that people are used to seeing it time and time again.

DebtScams.com, which provides information on current scams and types of scams, appears as a new site on the internet. They’ve poked fun at the Nigerian scam with “Scam a Friend.”

Scam a Friend” works by the visitor first entering information such as pizza topping, shoe size, and favorite cartoon character. The site then create a new “not-quite-Nigerian scam” letter that can optionally be emailed to a friend.

From a marketing perspective, the hardest part of creating a successful site is driving traffic to it. Debtscams has taken the approach of creating a unique experience that is interactive and self-advertising (their link is in the e-scam e-mail). Driving traffic usually occurs through search engine optimization, advertising, news/blog articles, and word-of-mouth. This qualifies as a bit of word-of-mouth and has the potential of getting blog traffic.

So will this work for them? Only time will tell.

Comments

AltonBrown.com - Pro and Con of Personal Sites

Alton Brown is considered an icon by many in the kitchen. He hosts the show Good Eats on the Food Network. I’m a fan and have been lucky enough to meet him and get an autograph. All that aside, he has a personal web site. Why?

Alton Brown has become a recognized name. The show is in the 9th(?) season and he also is host on Iron Chef America. He’s even got his name on a few kitchen knives.

Having his own web site allows creativity beyond the constraints of the Food Network.

In his case, AltonBrown.com initially provided links to buying AB products, book reviews, reader submitted recipes, and his own rant blog.

The problem with such a web page is keeping it up to date or better yet, giving people a reason to go there. For AB, the monthly rant was a great read and a reason to return. Then came his request for people to send in photo’s / descriptions of what they have on their refrigerator. Boy did he get an eyeful. Based on his last rant, people sent great cool photo’s but they also sent some obscene material. His rant expressed disgust and an attitude of “forget you guys, why should I even bother!”

At first, I’d heard he just didn’t have time to keep up his web site and that it was going to stay the same.

One day, word spread he was going to redesign his site. If I recall, that was in October of 2005. Finally, around Christmas time, the new Alton Brown web site came out.

I love it. The site is attractive. The text is funny and light-hearted - just look at the Alton Brown Privacy Policy.

Then I read the golden words:

Pretty soon there will be a darned clever podcast, video, all sorts of goodies for the eyes and brain alike.

It’s been over a month since the site went live and I am reading those same words. Nothing has been added. No podcast, no video, no picture of Alton stuffing seafood into an ice cream machine.

I’m not writing to say “How dare you, Alton Brown!” I’m writing to say…life gets busy. Working (earning an income), playing with the kids, and spending time with the wife are more important than updating a personal web site. I can’t blame the guy if he doesn’t update his web site every month.

What would I do if I were Alton? I’d add a blog onto the home page. Then I’d post something like;

“I’ve been busy with x, y, and z. I’ve thought of doing a monthly podcast but finding the time for such a venture is harder than I thought. I wish I could give a date for it to finally happen but I can’t.

In the meantime, here’s a bit of trivia about Good Eats. The ______ on the refrigerator you see this season is a ________ I picked up at _______.”

The point here is I’d be updating the site. I’d let people know what was going on and give them a little cool exclusive gift - information about Good Eats only available from my site.

Then if I didn’t have anything new in a month, I’d post something similar. I’d also link in some “behind the scene’s photo’s from a recent show like Good Eats or Iron Chef America.

Updating a web site is important when your web site SAYS you will be updating it. Alton’s site is a personal site, he can do whatver he wants with it. It’s not going to affect his income. However, if you run a web site as part of your business, you better provide updated content and give people a reason to some back. The more they return, the more likely they are to buy from you because you are building trust with updated quality content.

Comments (1)

SEO LINKS: Free Tools

I was reading information about a search engine optimization product called Traffic Blazzer.

Traffic Blazzer charges a subscription fee for using their service. I took their list of “this is what you get” and started looking for free online tools that do the same thing. I’m not saying that Traffic Blazzer is a poor product. I’m not saying it’s a great product. I’ve never used it! I do think the idea of consolidated tools in one application is a great idea, so I’ll give them kudo’s for that.

Based on Traffic Blazzer and the tools I’ve used myself, I’ve come up with this list of free seo products. OK, there are a few pay products but those are marked with an $.

If Traffic Blazzer works for you, then I’m glad to hear it. If you want to save a little money or you’re just cheap, consider this list:

Blog Search Engine Submission:
I’ve always done this manually to a good 6-8 primary blog directories…total time around 30 minutes.

Automated Search Engine and Directory Submission:
“Traffic Blazer submits your site to more than 200!” Big deal. Their are 5-10 primary search engines. Everything else isn’t wort the time submitting. You should not have to submit to search engines. If you can get an existing site to post your link then the search engines will index you faster than if you just submitted. Submit to an article site or in a popular forum, those work as well.

You only want the directories that are quality directories. Getting listed in the poorly viewed directories can hurt your rankings.

Site Analysis
Want to see how well your site is optimized?
web page analyser
keyword analysis tool

Keyword Optimization
This are gree free tools
keyword suggestions
keyword research tool
keyword analysis tool
$ wordtracker: some say worth it’s weight in gold.

Link Popularity Report
link popularity checker

List Checking Report
Just watch your site stats or use the keyword analyzer.

Alexa®/Google® Rank Checking
Alexa values are meaningless in my opinion (http://www.webmasterworld.com/forum10/10523-2-10.htm).
Use the free Google toolbar for tracking PR.

Keyword Ranking Report
keyword ranking

Regional Search Engines
regional search engines 1
regional search engines 2

Robots.txt/Robots Meta Tag Generator
Text Generator

One book to rule them all!
$ seobook

One great site with it’s own set of free webmaster tools:
webmaster-toolkit.com/

Comments

When to mention your price.

I had a meeting with a person today. I was paying for their services. Near the end of the meeting, they said something along the lines of …so you are wondering is this what I’m getting for $[dollars]…

I was fine with the fee they were charging. In fact, the meeting was far more beneficial than I’d expected.

What did bug me was they mentioned the fee price three times during the meeting in a similar fashion. It could be they knew I’m not a fan of paying out money if I don’t think it’s necessary. Therefore, they might have been attempting to easy my mind about the price. With that in mind…

A better method of qualifying a fee would be discussing, at the beginning of the meeting, the services that are being provided. There is no reason to remind me I am paying money. The more it’s brought up, the more I’m reminded about spending money. Whether it’s worth it or not, that doesn’t matter. When meeting with clients, explain your services and the agenda but don’t bring up the price. You’ve already got them paying your fee.

One other bit that bugged me was on their desk was a credit card processing machine. We didn’t talk across they desk but that machine was in my direct line of sight over their shoulder. Guess what, suddenly I’m thinking about money…and it was sometimes hard to focus on our discussion.

When you are dealing with a client, don’t let little things in your office become big destractions.

Comments

« Previous entries ·