Feeds:
Posts
Comments

Archive for September, 2007

Here is a little piece of code to get your way around with Excel in VB .Net using VS 2005.

    Dim objExcel As Excel.Application
    Dim objWorkBook As Excel.Workbook
    Dim totalWorkSheets As Excel.Worksheet
    Dim objWorkSheets As Excel.Worksheet
    Dim ExcelSheetName As String = “”

    objExcel = CreateObject(“Excel.Application”)
    objWorkBook = objExcel.Workbooks.Open(“C:\myExcel.xls”)

    ‘ this code gets the names off all the worksheets 
    For Each totalWorkSheets In myWorkBook.Worksheets
      ExcelSheetName += totalWorkSheets.Name
    Next totalWorkSheets

Read Full Post »

If you would like to find some charater/s in a column in the table and replace it here is a simple querry.

Note: For beginner please make sure you know what an update statement does. This query is going to update the column values in your table. So if you are just testing please use the Select statement instead. I have added it to the bottome of this article.

Approach 1:
Update T
       Set T.Col1 = Replace (T.Col1, “@” , ‘at’)
       From MyTable T

But If we just want to make it a bit faster depending on the size of your table.
Approach 2:
Update T
       Set T.Col1 = Replace (T.Col1,”@”,’at’)
       From MyTable T
       Where T.Col1 like (“@”)

You can have a hang of what the Replace functions does from the following link. But I would give you a little idea over here too. The Replace function look for the string that you have provided as the second parameter in the table column or string expression  that you have provided as the first parameter and simply replaces that string with the third parameter.

*Select Replace(T.Col1,”@”, ‘at’) As [ColName]
      From MyTable T

Digg!
 

Read Full Post »

Once again I am blogging about the Regular expresisons at work.

Here is a link to my previous blog. I guess now I have become an addict to using Regular Expressions to make life easier and am now longer a newbie to them.

Today I just came accross the task of cleaning the users input string on one of my forms free from all the HTML tags. I decided to google this and found a really nice piece from code from Jóhann Gunnarsson.

Code in VB.NET

      Dim RegExStr As String = “<[^>]*>”
      Dim R As New Regex(RegExStr)
      TempStr = R.Replace(TempStr, ” “)

Only three lines of code and your string is free from HTML tags, its a beauty.

Digg!

Read Full Post »

I was taken by surprise when one of my servers hung up. No web site was showing I was getting an error of service not available message in my explorer. I remotely logged into my server and found out that one of  the drives had run out of space; and the disk cleaning utility had fired up and was running consuming all the resources of my server. That was bad news for me.

So I decided to create a utility for alerting myself before time and here is a piece of code that I would like to share.

I am using the new class of DriveInfo available in .Net 2.0 in the System.IO namespace.

I simply send an email alert at my address informing me that its time for re-actions 🙂 .

    Dim CDriveFreeSpace As Long = 2147483648                                    2GB
    Dim DDriveFreeSpace As Long = 1073741824                                    1GB

    For Each curDrive As DriveInfo In My.Computer.FileSystem.Drives
      If curDrive.DriveType = DriveType.Fixed Then
        Dim theFreeSpace As Long = curDrive.AvailableFreeSpace
        If curDrive.Name = “C:\” And theFreeSpace <= CDriveFreeSpace Then
                  ‘ send mail
        End If
        If curDrive.Name = “D:\” And theFreeSpace <= DDriveFreeSpace Then
                  ‘ send mail
        End If
      End If
    Next

You can use the code as you like create a VB application, schedule it or else and please do share with me in what different ways can one use this code to solve the problem that I have just encountered.

Digg!

Read Full Post »

Well another revolution by Microsoft is on its way.

Silverlight has been officially released.

 

I have developed a little web application using Windows Expression Blend and Visual Studio Orcas and was really impressed. Well being a web developer I can forecast that this lethal combination of MS to integrate animation and the basic web is awesome. It was always a nuisance to include flash files into the web projects that I used. And the biggest catch was that a developer was really not able to manipulate the time sequences that were available in the animation. So Silverlight enabled project gives you more FREEDOM to work around with the animations to bring your web application to life.


Digg!

Read Full Post »

Hi folks this is the second time I am posting about yet another event by Mr. Syed Najam Ahmad who is the first Pakistani Qualified Google Advertising Professional.

Yep Najam is coming up with another workshop on the 9th of September in Islamabad a continuation of the one held in Feb this year. Link back.

Its a one day workshop on PPC (Pay Per Click Advertising) and SEO (Search Engine Optimization) so register now.

The most important ingredients in the best performance of any website strictly lies in PPC and SEO.

So make your e-commerce or even profile websites google friendly by using the tips and tricks by Najam.


Digg!

Read Full Post »