ads

Sunday, December 9, 2007

Add Google Search Code on your Website


Add Google Search in your Website
Just Copy & Paste the code below on your Site




Friday, December 7, 2007

Basic SQL Part 1

Select Statement
 
Sample Statement
Select * From Receipt
 
* = Wildcard or to Display all the Field in a Table
Receipt = Name of the Table.
 
Sample OutPut
IMPORTANT NOTICE:
The information in this email (and any attachments) is confidential. If you are not the intended recipient, you must not use or disseminate the information. If you have received this email in error, please immediately notify me by "Reply" command and permanently delete the original and any copies or printouts thereof. Although this email and any attachments are believed to be free of any virus or other defect that might affect any computer system into which it is received and opened, it is the responsibility of the recipient to ensure that it is virus free and no responsibility is accepted by American International Group, Inc. or its subsidiaries or affiliates either jointly or severally, for any loss or damage arising in any way from its use.

Basic SQL Part 1

Select Statement
 
Sample Statement
Select * From Receipt
 
* = Wildcard or to Display all the Field in a Table
Receipt = Name of the Table.
 
Sample OutPut
IMPORTANT NOTICE:
The information in this email (and any attachments) is confidential. If you are not the intended recipient, you must not use or disseminate the information. If you have received this email in error, please immediately notify me by "Reply" command and permanently delete the original and any copies or printouts thereof. Although this email and any attachments are believed to be free of any virus or other defect that might affect any computer system into which it is received and opened, it is the responsibility of the recipient to ensure that it is virus free and no responsibility is accepted by American International Group, Inc. or its subsidiaries or affiliates either jointly or severally, for any loss or damage arising in any way from its use.

XOR Encryption in VB


Public Function XOREncryption(CodeKey As String, DataIn As String) As String
Dim lonDataPtr As Long
Dim strDataOut As String
Dim intXOrValue1 As Integer, intXOrValue2 As Integer



For lonDataPtr = 1 To Len(DataIn)
'The first value to be XOr-ed comes from
' the data to be encrypted
intXOrValue1 = Asc(Mid$(DataIn, lonDataPtr, 1))
'The second value comes from the code ke
' y
intXOrValue2 = Asc(Mid$(CodeKey, ((lonDataPtr Mod Len(CodeKey)) + 1), 1))
strDataOut = strDataOut + chr(intXOrValue1 XOr intXOrValue2)
Next lonDataPtr
XOREncryption = strDataOut
End Function


'USAGE
Private Sub cmdEncryptdecrypt_Click()
Dim strCodeKey As String
strCodeKey = InputBox("Please enter your password", "XOr Encryption")
txtSource.Text = XOREncryption(strCodeKey, txtSource.Text)



End Sub


Tuesday, October 23, 2007

Read INI File in VB ( Visual Basic )

Declare
Public Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long


Code Function
Private Function INIRead(iAppName As String, iKeyName As String, iFileName As String) As String

Dim iStr As String

iStr = String(255, Chr(0))
INIRead = Left(iStr, GetPrivateProfileString(iAppName, ByVal iKeyName, "", iStr, Len(iStr), iFileName))

End Function

Sunday, September 16, 2007

C# Link Generate to HTML Code

Here is a sample program where user can generate HTML Link code just by inputing the address and description of the Site.. then the application will automatically generate the code

screen shot
Source Code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace Link
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
String linkname = "", linksite = "", linkdesc = "", linkResult;
linkname = textBox1.Text;
linksite = textBox2.Text;
linkdesc = textBox3.Text;
string link = "" + linkname + "";
if (textBox4.Text != "" )
{
textBox4.Text += "
" + link;
}
else
{
textBox4.Text = link;
}
}
private void button2_Click(object sender, EventArgs e)
{
textBox4.SelectAll();
textBox4.Copy();
}
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
WebBrowser web = new WebBrowser();
linkLabel1.Text = SiteAdvertise(1);
web.Navigate("http://zoul1380.blogspot.com","_new");
}
}
}

Monday, September 3, 2007

C# Sample Code : Exercise Palindrome

Filename: Program.CS



using System;
using System.Collections.Generic;
using System.Text;

namespace Exercise_02___Palindromes
{
class Program
{
//string aword;

static void Main(string[] args)
{
bool wResult;

Console.WriteLine("Palindrome Checker");


for (int x = 0; x < 20; x++)
{
Console.Write("=");
}
Console.WriteLine();
Console.Write("Input String : ");
string aword = Console.ReadLine();

clsCheckWord CheckWord = new clsCheckWord();

CheckWord.Givenword = aword;
int ix = CheckWord.isPalindrome();

if (ix == 1)
{
Console.Write("Result : A Valid Palindrome");
}
else
{
Console.Write("Result : Not A Palindrome");
}

Console.ReadLine();
}
}
}




Class Filename : clsCheckWord.cs




using System;
using System.Collections.Generic;
using System.Text;

namespace Exercise_02___Palindromes
{
class clsCheckWord
{
public clsCheckWord(){}

public string givenword="";

public string Givenword
{
get { return givenword; }
set { givenword = value; }
}

public int isPalindrome()
{
string tmpcomp="";

for (int x = 0; x < givenword.Length; x++)
{
tmpcomp = givenword.Substring(x, 1) + tmpcomp;
}

if (tmpcomp == givenword)
{
return 1;
}
else
{
return 0;
}
}
}
}

Monday, May 7, 2007

I.T. Organization & Management



April 23, 2007

Organizational Behavior

A contemporary field focusing on behavioral perspectives on management.

- draws on psychology, sociology, eonomics, and medicing -> interdischiplinary

Important topic in organizational behavior research:

- Job satisfaction and job stress

- Motivation and leadership

- Group dynamic and organizational politcis

- Interpersonal conflict

- The structure and design of organiztions


Click here to Download Full Article


----------------------------------------

April 25, 2007

Something…

Strategic Planning Tools

- SWOT Analysis

- Poter’s Generic Strategies regarding

o Cost

o Differentation

o Focus

- Porter’s 5 forces

- Porter’s value chain model

- Strategies based on product life cycle

SWOT = Strenght Weakneses Opportunities Threats


Click here to download full article

------------------------------------

April 27, 2007

INFORMATION TECHNOLOGY

- Definition

COMPUTER TECHNOLOGY (hardware & software)

for PROCESSING & STORING INFORMATION

as well as

COMMUNICATION TECHNOOGY

For TRANSMITTING INFORMATION

COMPETING IN AN eWORLD

- NEW WAYS to COMPETE: USING CAPABILITIES

o Particularly INTERNET

o MASS CUSTOMIZATION

§ Manufacturing customized prodcuts in large quantities

§ Eg.

· Dell

o Global Reach

§ Being able to market and sell anywhere in the world

§ Eg.

· Amazon.com

· Dell

o SUPPORT

§ 24/7 on-line support anywhere in the world


Click here to download full article

----------------------------

May 2, 2007

Decision Support Systems

- A computer based system, usually interactive, designed to assist managers in is making decisions.

- Incorporates both data & model

- Intended to assis in the solution of semi- or unstructured problems

- Data often extrated from

o TPS (Transaction Processing Systems)

o Data warehose

Click here to download full article

----------------------

May 4, 2007

Initiating the Purchasing Process

- Business manager makes a formal request to begin an investigation of a possible system purchase

o Proposed application needs

o Potential benefits

- Project team is established

- Project team is established & given the responsibility of acquiring the software

o IS analysis & other IS specialists

§ Who can help assess thebenefits and risks from an IT implementation perspective

§ Who will operate and support

· The package system

· Other packaged system that will interface with this package

- Representative from the business unit

o Who can assess the organizational benefits and risks

o Who will eventually implement & use the system


Click here to download full article

------------

May 7, 2007

6. Evaluate Vendor Responses to RFP & Choose the package

- Use criteria (mapped out in step 4) as basis for evaluation

- Deterine weights

- Evaluation criteria 1 – 10 (10 = perfect)

- Multiplyevaluation by weights to get weighted evaluation

- Add all weighted evaluation to get final scores

- Use these scores to discuss strengths and weaknesses of major candidate packages

Click here to download full article

Saturday, April 28, 2007

Learning Visual C++ Win32 Programming

I will be trying to learn Visual C++ Win32 Programming Come Join me thrue my journey in learning this programming language.. i will be posting all my Daily experience on this topic hope you can learn with me... and Join me on my Journey.....

Friday, April 6, 2007

Basic array operations in VB.NET

The ability to work with arrays is important in any programming language. VB.NET offers a simple way of grouping data into the array structures similarly to other languages. In this article, I will look at array declaration and usage.

Purpose of the arrays

Arrays are generally used for storing similar types of values or objects. They allow grouping variables together and allow referring to them by using an index. Arrays have an upper bound and a lower bound, which simply refer to the starting index and the ending index of a given array structure. Additionally, the data in the array can be sorted. Simple arrays are one-dimensional; however, you can also use multi-dimensional arrays in VB.NET. You can loop through an array to determine and to modify the values stored in the array.

Declaring and initialising arrays

There are two ways of initialising the arrays: to declare and initialise them in one statement, or to declare an array and choose to initialise it later.

When declaring and initialising arrays in the same statement, you must specify the type of the array elements and the number of the elements the array will hold. In VB.NET, arrays are zero based, which means that the index of the first element is zero. The elements are numbered sequentially. You must specify the number of array elements by indicating the upper bound of the array. The upper bound is the number that specifies the index of the last element in the array. Listing A shows the declaration and initialisation of an array of integers.

Listing A

Dim arrNumbers(4) As Integer 'Declares & initialises an array of 5 integers, with indexes ranging from 0 to 4

Another way to declare and initialise arrays is to perform these operations in two separate steps. If you declare an array without specifying a number of elements on one line, you have to provide the values for each item of the array when you initialise it. The initial values are provided enclosed in the {} braces, using a comma as a separator. Listing B shows the declaration and initialisation of an array in two separate steps.

Listing B

Dim arrNumbers() As Integer 'Declares the array of integers
arrNumbers = New Integer() {0,1,2,3,4} 'Initialises the array to five members & sets their values

Once an array is declared and initialised, it's possible to change the size of an array in run time by redefining it. You can use the ReDim statement to change the number of items in an array structure. Listing C shows declaration, initialisation, and then re-sizing of an array structure.

Listing C

Dim arrNumbers(32) As Integer' Declares & Initialises an array of integers
ReDim arrNumbers(45) As Integer' Re-initialises the array

By default, the data stored in an array is lost whenever an array is re-initialised. However, you can use the ReDim statement with the Preserve keyword in order to keep the existing data in the array when it's being re-initialised. Listing D re-initialises an array structure using the Preserve statement to keep the data already stored in the array.

Listing D

Dim arrNumbers () As Integer = {0,1,2,3,4}' Declares & initialises the array
ReDim Preserve arrNumbers (25) 'Resizes the array, but retains the data in elements 0 through 4

There are two types of multidimensional arrays: rectangular or jagged. In rectangular arrays, every member of each dimension is extended into the other dimensions by the same length. In jagged arrays, individual members of one dimension can be extended into other dimensions by different lengths. The more dimensions an array has, the more complex it becomes to work with it

Tuesday, March 6, 2007

How to use Direct Memory Access to do Graphics

How to use Direct Memory Access to do Graphics
One of the easiest ways to speed up your graphics is to use the native API calls rather than the built in graphical methods. For example, using the API functions GetPixel and SetPixel is about 3x faster than using the built in methods PSet and Point. But while the the API is fast, you can get even better performance with direct memory access (DMA).

But wait! What about DirectX? Well, DirectX is great and is extremely fast for complex operations but most of its speed comes from its ability to interact with the coprocessor in your graphics card. If you don't have such a card (unlikely, true, but there it is) or if you are doing simple graphics (line and point stuff), then DMA is just as fast. Plus you don't need to distribute any particular version of DX.

Besides, I just like DMA. DX hides a lot of the logic of graphics which is great, but sometimes you can learn quite a bit from the algorithms behind a line, or a floodfill.

Anyway, here is how you do DMA.

The basic idea is that you access the actual bitmap that makes up the picture. You can do this indirectly by using the API functions GetDIBits and SetDIBits which extract a bitmap into an array and copy an array to a bitmap respectively, but you can do it directly if you had an array that pointed to the actual memory used by the bitmap.

To make such an array requires some API calls of course. Here they are:

Code:
Private Declare Function VarPtrArray Lib "msvbvm60.dll" Alias "VarPtr" _
(Ptr() As Any) As Long
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" _
(pDst As Any, pSrc As Any, ByVal ByteLen As Long)
Private Declare Function GetObjectAPI Lib "gdi32" Alias "GetObjectA" _
(ByVal hObject As Long, ByVal nCount As Long, lpObject As Any) As Long

Private Type SAFEARRAYBOUND
cElements As Long
lLbound As Long
End Type

Private Type SAFEARRAY2D
cDims As Integer
fFeatures As Integer
cbElements As Long
cLocks As Long
pvData As Long
Bounds(0 To 1) As SAFEARRAYBOUND
End Type

Private Type BITMAP
bmType As Long
bmWidth As Long
bmHeight As Long
bmWidthBytes As Long
bmPlanes As Integer
bmBitsPixel As Integer
bmBits As Long
End Type
The VarPtr function can get the actual memory address of a variable. In this case, we type the function in such a way that it works on arrays and we call it VarPtrArray. The CopyMemory function can copy data from one memory location to another. The GetObjectAPI function can retrieve information out of an object. In this case, we will use it to extract the BITMAP information from a stdPicture object, thus we need to define a BITMAP structure. Finally, we define a SAFEARRAY structure since this is the raw format behind an array and we need to mess with this to get this method to work.

So we start with a stdPicture object. We will assume that this object has a picture loaded. We also have a dynamic array of bytes, but this array has not yet had any memory assigned to it. We then use our API functions to assign the memory used by the picture object to the array, thus any changes we make to the array will show up in the picture.

Here is how we do it:

Code:
Dim SA As SAFEARRAY2D
Dim BMP As BITMAP
Dim mvarBytesPerPixel

Public Sub LoadPicArray(p As StdPicture,Data() As Byte)
If GetObjectAPI(p.Handle, Len(BMP), BMP) Then 'retrieve bitmap information about p
mvarBytesPerPixel = BMP.bmWidthBytes \ BMP.bmWidth
' make the local matrix point to bitmap pixels
With SA
.cbElements = 1
.cDims = 2
.Bounds(0).lLbound = 0
.Bounds(0).cElements = BMP.bmHeight
.Bounds(1).lLbound = 0
.Bounds(1).cElements = BMP.bmWidthBytes
.pvData = BMP.bmBits
End With
' copy bitmap data into byte array
CopyMemory ByVal VarPtrArray(Data), VarPtr(SA), 4
End If
End Sub
So what happened? Well, first, we use the GetObjectAPI function to extract the BITMAP info. We then use this information to set up the SA SafeArray2D structure. In particular, notice the line:
.pvData = BMP.bmBits
which assigns the memory stored in the bitmap to the SA structure.

Now we simply make the Data array point to the SA structure with the CopyMemory function while using the VarPtr functions to get the actual memory addresses of the SA structure and the array.

Simple? Well, not exactly....there are some caveats...
1) The Picture object MUST have a picture preloaded. This will set up the objects BMP structure. Otherwise, it will be uninstantiated.
2) The SA object MUST persist for the life of the array. Remember, the array points to the SA structure so if you destroy SA before you terminate the array, the array will point to nothing.
3) Before you destroy the array, you MUST reset it to point to null, otherwise you can crash the program or get a memory leak.
4) A 256 color Bitmap has 1 byte per pixel, but this byte is a palette index, not a color. So you need to convert colors into palette indexs before setting the array. The same applies to 16bit HiColor bitmaps. Fortunately, TrueColor (24bit) images are the actual colors, although you need to set each RGB byte individually.
5) Oddly enough, the array is mapped from the bottom up. In other words, array point 0, 0 is the BOTTOM left corner.

After you are done, you must reset the array. Here is how you can do it:
Code:
Public Sub ReleaseData(a() As Byte)
CopyMemory ByVal VarPtrArray(a), 0&, 4
End Sub
So now how do you use the array?

Well, the array is now a 2D array of the form Data(X, Y) where X is the column and Y is the row. Each element of the array is a byte. For 256 color bitmaps, this byte is a palette index for that pixel. But for 24 bit images, each byte is a colour value (BGR) for a pixel, so each pixel consists of 3 consecutive bytes. eg a 100pixel by 100 pixel image would generate an array 300x100 in size.

Since the array can vary in size, you have to take that into account when making functions to set or read a pixel. For instance:

Code:
Public Sub DrawPixel(Data() As Byte, ByVal x&, ByVal y&, ByVal c&)
Select Case mvarBytesPerPixel
Case 1: Data(x, y) = c And &HFF
Case 2
Data(x + x, y) = (c \ 256) And &HFF
Data(x + x + 1, y) = c And &HFF
Case 3
Data(x * 3, y) = (c \ 65536) And &HFF
Data(x * 3 + 1, y) = (c \ 256) And &HFF
Data(x * 3 + 2, y) = c And &HFF
End Select
End Sub

Public Function ReadPixel(Data() As Byte, ByVal x&, ByVal y&) As Long
Select Case mvarBytesPerPixel
Case 1: ReadPixel = Data(x, y)
Case 2: ReadPixel = Data(x + x, y) * 256& + Data(x + x + 1, y)
Case 3: ReadPixel = ((Data(x * 3, y) * 256&) + Data(x * 3 + 1, y)) * 256& + Data(x * 3 + 2, y)
End Select
End Function
Here is a comparison of speed.

With a 100x100 24 bit bitmap loaded, I set each and every pixel to red using DMA, SetPixel and PSet. The time results were 5ms, 60ms and 550ms respectively. After compiling, the speeds were 4 ms, 50 ms and 70ms. So DMA was around 12x faster than SetPixel.

I've attached a class module to encapsulate the technique. Just compile the class into an ActiveX DLL and then reference it in your own projects. Here is my speed test program that demonstrates how to use this DLL:

Code:
Option Explicit
Private Declare Function GetPixel Lib "gdi32" _
(ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long
Private Declare Function SetPixel Lib "gdi32" _
(ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long) As Long
Private Declare Function timeGetTime Lib "winmm.dll" () As Long
Dim pa As BCHPicArray.clsPicArray

Private Sub Command1_Click()
Dim x&, y&, t&
t = timeGetTime()
For y = 0 To Picture1.ScaleHeight - 1
For x = 0 To Picture1.ScaleWidth - 1
pa.DrawPixel x, y, vbRed
Next x
Next y
t = timeGetTime() - t
Picture1.Refresh
Me.Caption = "PicArray=" & t
t = timeGetTime()
For y = 0 To Picture1.ScaleHeight - 1
For x = 0 To Picture1.ScaleWidth - 1
SetPixel Picture1.hdc, x, y, vbRed
Next x
Next y
t = timeGetTime() - t
Picture1.Refresh
Me.Caption = Me.Caption & " SetPixel=" & t
t = timeGetTime()
For y = 0 To Picture1.ScaleHeight - 1
For x = 0 To Picture1.ScaleWidth - 1
Picture1.PSet (x, y), vbRed
Next x
Next y
t = timeGetTime() - t
Picture1.Refresh
Me.Caption = Me.Caption & " PSet=" & t
End Sub

Private Sub Form_Load()
Set pa = New clsPicArray
pa.LoadPicArray Picture1.Picture
End Sub

Private Sub Form_Unload(Cancel As Integer)
Set pa = Nothing
End Sub

Google Search