Saturday, October 27, 2007

Programming Tool Box : Recycle Bin

Private Declare Function SHFileOperation Lib _
"shell32.dll" (ByRef lpFileOp As _
SHFILEOPSTRUCT) As Long

Private Const ERROR_SUCCESS = 0&
Private Const FO_COPY = &H2
Private Const FO_DELETE = &H3
Private Const FO_MOVE = &H1
Private Const FO_RENAME = &H4
Private Const FOF_ALLOWUNDO = &H40
Private Const FOF_CONFIRMMOUSE = &H2
Private Const FOF_FILESONLY = &H80
Private Const FOF_MULTIDESTFILES = &H1
Private Const FOF_NOCONFIRMATION = &H10
Private Const FOF_NOCONFIRMMKDIR = &H200
Private Const FOF_RENAMEONCOLLISION = &H8
Private Const FOF_SILENT = &H4
Private Const FOF_SIMPLEPROGRESS = &H100
Private Const FOF_WANTMAPPINGHANDLE = &H20

Private Type SHFILEOPSTRUCT
hwnd As Long
wFunc As Long
pFrom As String
pTo As String
fFlags As Integer
fAnyOperationsAborted As Long
hNameMappings As Long
lpszProgressTitle As String ' only used if FOF_SIMPLEPROGRESS
End Type



'--create public sub---


Public Sub Recycle(ByVal FileName As String)
Dim CFileStruct As SHFILEOPSTRUCT

With CFileStruct
.hwnd = Me.hwnd
.fFlags = FOF_ALLOWUNDO
.pFrom = FileName
.wFunc = FO_DELETE
End With

If SHFileOperation(CFileStruct) <> ERROR_SUCCESS Then
'An error occurred.
End If

End Sub


'---create command button---

Private Sub Command1_Click()
Recycle "c: est.txt"
End Sub


Technorati Profile

Programming Tool Box: Multiplication Table

#include
#include

int main()
{
int table_size = 5;
int row = 0;
int col = 0;

clrscr();

textcolor(GREEN);printf("Multiplication Table\n");
for(col=0 ; col<=table_size ; col++)
{
printf(""); /*printf("%d", col);*/
}

for(row = 0 ; row<=table_size ; row++)
{
printf("\n");

for(col = 0 ; col<=table_size ; col++)
{
if(row == 0)
{
if(col == 0)
{
printf(" ");
}
else
{
printf(" |%d", col);
}
}
else
{
if(col == 0)
{
printf(" %d", row);
}
else
{
printf(" |%d", row*col);
}
}
}
}
printf("\n");

getch();
}


Programming Tool Box: Area Computation - C++

#include
#include

#define p printf
#define s scanf

main()
{
char opt I, i, F1, F2, F3
float a, b, c, b1, b2, AR

clrscr()

p("Main Menu\");
p("[R] RECTANGEL");
p("[C] CIRCLE");
p("[S] SQUARE");
p("[T] TRIANGLE");
p("[E] EXIT");
p("\nChoose a letter: ");


s("%s", &opt);
if(opt=='R'||opt=='r');
{
clrscr();
p("\n RECTANGLE");
p("[I] inches");
p("[F] feet");
p("\nChoose a letter: ");
s("%s", &opt);
if (I=='s' || i=='I');
{
clrscr();
p("base:");
s("Heigtht:");
s("%f", &b2);
p("lenght");
s("%f', &b3);
AR=b1*b2*b3;
p("the area is %f", AR)
getch();
main();
}
if (I=='f'|| F=='f');
{
main()
clrscr();
p("\n CIRCLE");
p("[] inches");
p('[] feet");
p("Choose a letter");
s("%s", &opt);
if (I=='s' || i=='I');
{
if(opt=='S' || opt=='s');
getch();
main()
}
if(opt=='T' || opt=='t');
{
main();
clrscr();
p("\n TRIANGLE");
p("[] inches");
p("[] feet");
p(" Choose a letter");
p("%s", &opt);
if(I=='i' || i=='I');
{
main()
clrscr();
getch();
main()
}
if(opt=='E' || opt == 'e');
else
p('Invalid Input');