Monday, September 18, 2006
Monday, February 27, 2006
.NET Useful Link : Create Property Macro
Here is the magic.
Create Property Macro for VS.NET
http://www.reflectionit.nl/Macro.aspx
Thanks to Fons Sonnemans.
Sunday, February 12, 2006
Top Ten Web-Design Mistakes
Top Ten Web-Design Mistakes of 2002
Top Ten Web Design Mistakes of 2003
Top Ten Web Design Mistakes of 2005
Good WebSite for Web Design
useit.com: Jakob Nielsen's Website
http://www.useit.com/
Saturday, January 14, 2006
Easy - Reg/Unreg DLL for VB6
The next thing that would happen in the Windows explorer is probably you clicking on one of the menu items. Let's use Open as an example. Go back to the Registry Editor and expand the Open subkey under shell. You'll see another subkey called command. If you click on the command subkey, you'll see that the (Default) value has a value. If you double-click (Default), the Edit String dialog will open. If you're using the default text file editor installed by Windows, you'll see Notepad.exe somewhere in the string value. That means that Windows will use the Notepad.exe application to open files with the .txt extension. But how does Windows know what file to open? Well, the other thing you'll see, along with notepad.exe, is %1. %1 is a token that will be replaced on the fly with the name of the file you right-clicked on. So, let's say you were in the root on your C drive and you right-clicked on a file called foo.txt. When you click the Open item, the shell launches notepad passing c:\foo.txt on the notepad command line, which instructs notepad to open the file. That's all there is to it! Take a quick look at the print subkey under shell. This item provides the command line for printing text files. You see how it's done. The Shell calls notepad and passes a /p and %1 (the file name) on the command line. The /p instructs notepad to print the file it opens. Piece of cake right?
But Why?
By now, you're probably wondering what all this has to do with VB. Well, I use this information to help me work with files that we VBers typically work with. Let's say you create quite a few DLLs in you current assignment. If you do, you know that quite often, you find yourself registering and unregistering DLLs while you test. You may open a DOS box or you may open the Run dialog, but you end up somewhere typing in
regsvr32 C:\the very long\path to a DLL\I wrote in VB\yesterday\foo.dll
What a drag eh? Well, never again. What did we just learn? How to get the Shell to execute a command for us, based on the file extension. Ah, I see the lights coming on. Piece of cake right? Open the Registry Editor (if it isn't still open from before) and navigate your way to
HKEY_CLASSES_ROOT\dllfile
If there isn't already a subkey called shell under dllfile, create one. Under shell, create two new subkeys; Register and Unregister. Create a command subkey under each of these. In the (Default) value for the shell\Register\command subkey, enter
regsvr32 "%1"
For the shell\Unregister\command (Default) value, enter
regsvr32 -u "%1"
These command lines, as I'm sure you know, register and unregister COM DLLs. To try them out, open the Windows Explorer and locate one of your VB DLLs. Right click on it and, if we've done things right, Register and Unregister will appear in the context menu. Click Register and you'll see the familiar DllRegisterServer...succeeded message. You did it! You'll never have to type that command out again.
Other Ideas
Now that you have the basic idea, what else could you do? Well, I often find myself opening project files or forms in Notepad to look through them for something when I don't really feel like opening a new instance of VB. So what I did was add a new shell subkey for all my VB-related files like .cls, .frm, .vbp, and .vbg. As a quick refresher:
- navigate to HKEY_CLASSES_ROOT\.cls (for example)
- you'll see the (Default) value says VisualBasic.ClassModule
- navigate to HKEY_CLASSES_ROOT\VisualBasic.ClassModule\shell
- add a new subkey called Open with Notepad
- add a subkey under this called command
- set the (Default) value to
notepad.exe "%1"
You Can Take It From Here
You can apply this same set of steps to just about any file type in your system. Then, once you've added all the necessary subkeys and commands, you can just right click a file to get at your most commonly used commands! If you ever need to remove one of the commands you added, just delete the subkey under shell and it will go away.
This week's article may not be directly related to VB, but it is directly related to your productivity. The faster you can get things done, the more productive you'll be. It doesn't matter whether it's coding that new DLL, or registering it and unregistering quickly while you're testing; both add to your productivity!
Original
And Now, For Something a Little Different
Monday, January 02, 2006
Rpt - FormatWhiteSpace
In HTML,
<asp:Repeater id="Repeater1" runat="server">
<HeaderTemplate>
<table cellpadding=0 cellspacing=0 border=1>
<tr>
<td>Product Name</td>
<td>Unit Price</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td><%# DataBinder.Eval(Container.DataItem, "ProductName") %></td>
<td><%# FormatWhiteSpace(DataBinder.Eval(Container.DataItem, "UnitPrice")) %></td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
In vb,
''Change [ null,0 ] to ""
Protected Function FormatWhiteSpace(ByVal argVal) As String
If argVal Is DBNull.Value Then
Return " "
ElseIf argVal = 0 Then
Return " "
Else
Return argVal
End If
End Function
Sunday, January 01, 2006
Thousand Seperator
About Number
For Thousand Seperator [ Code Behind ]
Dim nfi As NumberFormatInfo = New CultureInfo("en-us", False).NumberFormat
Dim myint As Int64
Console.WriteLine(myint.ToString("N", nfi))
[ Repeater ]
<td align="right" nowrap="true"> <%# DataBinder.Eval(Container.DataItem, "BalAmount","{0:N}") %></td>
EXEC & EXEC sp_executesql
DECLARE @sql as nvarchar(100)
DECLARE @paraDOB datetime
SET @paraDOB = '1/1/1981'
SET @sql=N''
SET @sql=N'SELECT * FROM EmpMast'
SET @sql=@sql + ' WHERE DOB >= @paraDOB'
exec sp_executesql @sql,N'@paraDOB datetime',@paraDOB
If our str is over 4000, we can’t use sp_executesql.
DECLARE @sql as varchar(100)
DECLARE @paraDOB datetime
SET @paraDOB = '1/1/1981'
SET @sql=''
SET @sql='SELECT * FROM EmpMast'
SET @sql=@sql + ' WHERE DOB >= ''' + CONVERT(NVARCHAR,@paraDOB) + ''''
EXEC (@sql) --( ) is important.
When we use sp_executesql, we can pass hidden parameter. sp_executesql’s performance is better than EXEC.
[ some people pass all parameter if they use sp_executesql. Actually, we don’t need to pass all parameter ]
Date Valation Regualar Expression
Adding Style to Repeater Controls in runtime.
Dim htmlTblCell As HtmlTableCell
If e.Item.ItemType.AlternatingItem Or e.Item.ItemType.Item Then
htmlTblCell = e.Item.FindControl("tdOutDollars")
If Not htmlTblCell Is Nothing Then
If htmlTblCell.InnerHtml <> " " Then htmlTblCell.Style.Add("color", "green")
End If
End If
End Sub
<TDalign="right"nowrap="true"id="tdOutDollars" runat=server> <%# DataBinder.Eval(Container.DataItem,"OutDollars","{0:N}") %></TD>
Clear Old Msg
Tips : Dataview to DataTable
Dim dt As DataTable = dv.Table.Copy
Dim dsRtn As New DataSet(dv.Table.TableName)
dsRtn.Tables.Add(dt)
Return dsRtn
End Function
Thursday, December 29, 2005
SQL 2k Tips : UPDATETEXT
Sent: Tuesday, February 01, 2005 4:07 PM
Hi Micheal,
Do you know that ntext data type can’t do concatenation. To overcome this problem, we can use UPDATETEXT.
The following are the example of using UPDATETEXT.
DECLARE @ptrval binary(16)
Declare @strComments nvarchar(4000)
SET @strComments = 'comments'
SELECT @ptrval = TEXTPTR(rd.Comment)
FROM vyRequisitionDetails rd
WHERE rd.RequisitionID = 'REQPhyuHT02012005-Delhi'
UPDATETEXT vyRequisitionDetails.Comment @ptrval NULL 0 @strComments
Grace