Wednesday, April 26, 2006

How to strip extra lines in a file?

Problem :
Need a script to remove all the blank lines from a file.

Solution:

Save the following as strip.pl and use perl to run the script.

#############################################################
###################### Bipin C Nair #########################
##################### http://www.bipin.co.nr ################
#################### Written on 2003-12-23 ##################

$linecount = 1;
if ( $ARGV[0] )

{
$filename = $ARGV[0];
}
else
{
print "Specify file to strip of extra lines"; exit;
}
open(INFILE,"<$filename") die "can't write to your output file";

@mapfile = ;
close ( INFILE);
open(OUTFILE,">$filename") die "can't write to your output file";
foreach $line (@mapfile)
{
if ( $line =~ m/^\n/)
{
$line =~ s/^\n//;
}
print OUTFILE "$line";
$line = "";
$linecount = $linecount + 1;
}
print "Converted $linecount lines";

close(OUTFILE);
print "The file is stripped of extra line breaks, enjoy!!\n";exit;


© Copyright 2006. Bipin C Nair. All rights reserved.

Tuesday, April 25, 2006

How to insert a .NET control in VB?

Problem:

You are working for a legacy product in VB. You are asked to build a new component as a control. Since .NET is a great way to develop controls you build the control in .NET. But now how to add the new control in the VB form?

Solution:
1. Create ur control in .NET.
2. Make sure in your Config properties "Register for COM Interop" is set to true.
3. After the buils is successful register the library using
regasm YourDll.dll /tlb:YourDll.tlb
4. Add the tlb as reference in VB.
5. Create a custom User Control in VB.
6. Use CreateObject to load the control.

Note:
If CreateObject loads but does not display your control use a shim control provided by Microsoft to load the control.
More at http://msdn.microsoft.com/vstudio/downloads/samples/automation.aspx
This control was developed for Automation, but currently this is the only way to use a .NET control as an ActiveX.

Warning:
Microsoft doesn't support this kind of deployment. Infact this support was removed in .NET
http://discuss.develop.com/archives/wa.exe?A2=ind0107b&L=dotnet&F=&S=&P=16992
The above solution is a wok around that you can use.


© Copyright 2006. Bipin C Nair. All rights reserved.

Monday, April 24, 2006

How to assign a drive letter to any folder.

Problem:
I need to assign a drive letter for my app to work properly. How can I do that?

Solution:
Use something like..
subst S: C:\Documents
where S is the drive that the app looks for. Good to fool apps which looks for Floppy
subst A: C:\SomeFolder

Friday, April 21, 2006

How to enable name (mail id) suggestions in Microsoft Outlook?

Problem:
On a Monday morning suddenly you might find that your outlook is not auto completing the names when you type the initial few alphabets.
This might be because of your corporate policy, which might enforce this in order to avoid the mails being sent to unintended recipients unintentionally.

Solution:
1. Open regedit. (If you don't know how, back up ur comp gonna explode...)
2. Go to HKEY_CURRENT_USER\Software\Policies\Microsoft\Office\11.0\Outlook\Preferences
3. Change ShowAutoSug = 1

And don't forget to look carefully to see whom you are sending the mail.


© Copyright 2006. Bipin C Nair. All rights reserved.

Thursday, April 20, 2006

How to find a control in .NET given the control name.

Situation:
I've a lot of buttons in a Panel whose names are Button1 Button2 ...
I want to programatically change the Caption and the click event.

Problem:
How do I get the control from the control name.

Solution:
private Control FindControl(String ctrlName)
{
foreach(Control ctr in this.panelGeneral.Controls)
if (ctr.Name == ctrlName)
return ctr;
return null;
}


© Copyright 2006. Bipin C Nair. All rights reserved.

Wednesday, April 19, 2006

How to save the gif/jpg images embedded in a mail in Microsoft Outlook?

1. Make sure you've opened up the mail.
2. Bring up a command shell
3. type cd "%temp%\..\temporary internet files"
4. Look at the folders. Do a cd into the directory with the closest date/time stamp as your time
5. See if there is a gif file in there.
6. copy it away from there using "cd c:\image.gif" (for example)

Thx to NetRyder and Cider at http://channel9.msdn.com/ShowPost.aspx?PostID=29147

What you can find here?

Everytime I'm in need of some kind of tech help I search the whole web to find how to do it.
Most of the time it takes ages before I find what I searched for. The height is that I usually forget how I did that and starts searching again when I'm in need of the same thing again. Now the website where I found would have moved or is missing from shortcuts!!!

Here you can find some seeminly common tasks which actually is very difficult.

My Home
ആറന്മുള വിശേഷങ്ങള്
Globe Trotter