28 September 2007

FireFox has a grate Add-In which allows to save any web page to JPEG or PNG format.

It's Save As Image.

Click here to Download.

Save whole web page or you can also crop any part of that web site.

It's very useful.

27 September 2007

www.homepagestartup.com provides a very useful service that you can have multiple home page in a single browser.


It is automatically stores sites information in cookies and when you come back in this site again it will display the same, There is also Tab feature to manage more sites.

Just click on icon, add URL and save it.

You should have to register to get more features.

24 September 2007

One day when I was debugging the code. It started to show hexadecimal values automatically.

I don't know that how it was stared. and I also did not know that how to see decimal back at that time.

but it was simple option that was in Local Window that named "Hexadecimal Display".

Click on Debug Menu -> Windows -> Local.

Right Click on Local Window and get this option as pop-up menu.

19 September 2007

Create shapes on form as Visual Basic 6.0 can do that directly on the form.

Power Pack 2.0 is a line, shape controls, printform component, and printer compatibility library.

It has 4 controls.

There are so many property and event.

Download Microsoft Visual Basic 2005 Power Packs 2.0

17 September 2007

See MSDN Magazine in a book format.

Click Here.


Have fun with moving page...


There is also another magazine for "Dr. Dobb's Journal".

15 September 2007

I have created a user control "Any Drop Down List" anyDDL. Its use to show drop download list form database very quickly.

Lets create that user control.

I'm using Visual Studio 2005, Framework 2.0, SQL Server 2005, ASP.net, C# language to build it.

Start Visual Studio,
Click on Create New Web Site.
Select ASP.net web site.
Click on OK button.

Now,

click on Web Site menu or right click on project name in Solution Explorer.
Select menu named "Add New Item".
It will show a add item dialog box as bellow.


Select Web User Control there and right down its name anyDDL, click on OK button.

Now add a Drop Down List form toolbox.



Rename that drop down list with "thisDDL".

now add some following code in code behind file.



using System;
using
System.Data;
using System.Data.SqlClient;

/// This Drop down list can handle all kind of Values automaticaly.
///saCode 14Sep2007


public
partialclass userControls_anyDDL : System.Web.UI.UserControl
{
#region
private variables
private string _SQL;
private string _WhereSQL="";
private String _allowSelectionByUserValue;
#endregion

#region
Public Propertys
///SQL Stored Procedure Name Comes here.

public string SQLstring
{
get { return _SQL; }
set { _SQL =value; }
}

/// SQL where Condition
public string WhereValue
{
get { return _WhereSQL; }
set { _WhereSQL =value; }
}

/// Selected Value of Drop Down List Box
public string SelectedValue
{
get{ return ddlThis.SelectedValue;}
set{ddlThis.SelectedValue = value;}
}

/// Somthing like "---Other---" or "--Select--"
public string allowSelectionByUserValue
{
get { return _allowSelectionByUserValue; }
set { _allowSelectionByUserValue = value; }
}

#endregion

public void ReBindData()
{
BindWithData();
}

protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
BindWithData();
}
}

private void BindWithData()
{
if (SQLstring !=null)
{
string _strConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["myConnectionString"].ConnectionString;

SqlConnection _objCon = new SqlConnection(_strConnectionString);
SqlCommand _objCmd = new SqlCommand();
System.Data.
DataSet _objDataSet = new System.Data.DataSet();

_objCmd.Connection = _objCon;
_objCmd.CommandType = System.Data.
CommandType.StoredProcedure;
_objCmd.CommandText =
"uspAnyDll";

SqlParameter _paramSelectType = new SqlParameter("@selectType", System.Data.SqlDbType.VarChar);
SqlParameter
_paramWhereValue = new SqlParameter("@WhereValue", System.Data.SqlDbType.VarChar);

_paramSelectType.Value = _SQL;
_paramWhereValue.Value = _WhereSQL;

_objCmd.Parameters.Add(_paramSelectType);
_objCmd.Parameters.Add(_paramWhereValue);

SqlDataAdapter _objAdapter = new SqlDataAdapter(_objCmd);
_objAdapter.Fill(_objDataSet);

ddlThis.DataSource = _objDataSet;
ddlThis.DataTextField =
"Value";
ddlThis.DataValueField =
"ID";

ddlThis.DataBind();

if (allowSelectionByUserValue != null)
{
System.Web.UI.WebControls.
ListItem
_listItem =
new System.Web.UI.WebControls.ListItem(allowSelectionByUserValue, "0");
_listItem.Selected =
true;

ddlThis.Items.Add(_listItem);
}
if (this.SelectedValue != null)
{
ddlThis.SelectedValue =
this.SelectedValue;
}
}
else
{
//Throw Expression
}

}

}



Now we have to create stored procedure named "uspAnyDll" to get data form SQL Server.




-- =============================================
-- Author: <sa>
-- Create date: <15Sep2007>
-- Description: <saCode>
-- =============================================

CREATE PROCEDURE uspAnyDll
--ALTER PROCEDURE uspAnyDll
@selectType varChar(50),
@WhereValue varChar(50)
AS
BEGIN

SET
NOCOUNT ON;

BEGIN
TRY

--you can change this name and SQL as you database requirement.
--but don't change Field name , ID and Value both are static typed in that user control.

IF @selectType='GroupData'
SELECT GroupID AS [ID], Name AS [Value] FROM tblGroupWHERE RecordStatusID=1

IF @selectType='User Information'
SELECT UserID AS [ID], UserName AS [Value] FROM tblUser WHERE CompanyID=Convert(int, @WhereValue)

IF
@selectType='State'
SELECT StateID AS [ID], StateName AS [Value] FROM tblState

END
TRY
BEGIN CATCH
SELECT
'Error! : ' + @@ERROR
END CATCH

END


you can write down you own query here but don't change it's title "ID" and "Value", because those are static in user control code.

Thats all.
User Control is ready to run. open default.aspx page and drag this control from Solution Explorer.

It will display a drop down list control. See it property panel.


Here is the description for each property:

allowSelectionByUserValue : Some selection message. like "---Select---"
SelectedValue : any selected value if required.
SQLstring : SQL Server stored procedure parameter comes here.
WhereValue : any where condition to pass in that stored procedure.


See, here I have create three different select query in uspAnyDll.

I drag three times anyDDL, and pass SQLstring property as "GroupData', 'User Information' and 'State'. this are actually sql stored porcedure parameters.

and just press F5.

See the result.



Now, using this user control, you can get quickly bind data.

08 September 2007

Start to use isError formula in excel when you are calculating something.

I have seen many time error, In Excel.
  • #Ref
  • #DIV/0
  • #NAME?
You can remove all this error and also vice some user friendly value or message there by using ISERROR formula.

IsError(value) returns boolean value in True or False.

try some example in your excel sheet.

=IsError(1/0)

it will return TRUE, it mean there is some error.

Here in this case you can also vice some error message using if condition.

=IF(ISERROR(1/0), "Some Error!", 1/0)

or like that.

Ok, if you don't want to write down this formula every where in your calculation and you will see #NAME?, #Ref, #DIV/0 etc. messages in your excel screen, at list you should not print out them.

You can also hide those error when did you print.

Click on Page Setup.
Click on Sheet Tab.
there is a list box named "Cell error as".
See following image.


But, IsError formula is best, this formula is form Office XP version.

07 September 2007

Lets create Outlook 2007 Add-In using Visual Studio 2005.

If you have not installed VSTO then Download Microsoft Visual Studio 2005 Tools for Office Second Edition Runtime (VSTO 2005 SE) (x86).


Start IDE.

Click on File, New project

Select Outlook Add-In and Click on OK.

you will find some code like this:

Public
Class ThisAddIn
 Private WithEvents btn1 As Office.CommandBarButton

Private Sub ThisAddIn_Startup(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Startup

End Sub


Private Sub ThisAddIn_Shutdown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shutdown

End Sub

End Class


Now add following code in StartUp event:

Dim explorer As Outlook.Explorer = Me.Application.ActiveExplorer()  

If explorer IsNot Nothing Then

Dim bar As Office.CommandBar = explorer.CommandBars.Add("saAction Bar", Temporary:=True)

bar.Visible = True

btn1 = bar.Controls.Add(Office.MsoControlType.msoControlButton, Temporary:=True)

btn1.Caption = "saAction Button"

btn1.Tag = "myOutlookAddin1.btn1"

btn1.Style = Office.MsoButtonStyle.msoButtonCaption

End If

And declare Button click event any where in the class.

 Private Sub Btn1_Click(ByVal ctrl As Office.CommandBarButton, ByRef cancelDefault As Boolean) Handles btn1.Click

MsgBox("Hi! this is VSTO")

End Sub


Done.

Now, Just run the project. Press F5, Outlook will automatically start and It will show a button there, and click on that button. See below "saAction Button" and messagebox.



Outlook is a very big application and using VSTO, you can utilize it's functions.