Surendra Sharma

Surendra Sharma

Search This Blog

Monday, August 5, 2013

A module is not a valid type

How to fix error “Compile Error: A module is not a valid type” in VB?





Solution:-

This type of error occurred when you are trying to include old version of VB files or VB is unable to recognize the module.

How to fix it?

Copy the code of that particular module, suppose name is “Segmentation.cls”, in notepad file.

Select and Right click file “Segmentation.cls” -> Remove “Segmentation.cls”



Select and Right click Project -> Add -> Class Module -> New -> Select Class Module -> Open


Copy the code from notepad and paste to this new class module file. Save this with same filename “Segmentation.cls”.

Here file content should start with “Option Explicit”.
Content before this line should be commented or removed as below
'Attribute VB_Name = "Segmentation"
'VERSION 1.0 CLASS
'BEGIN
'  MultiUse = -1  'True
'End
Option Explicit

Select class module file in Project Explorer and change its Name property to “Segmentation” i.e. same as file name as below




Please leave your comments or share this tip if it’s useful for you.

Friday, August 2, 2013

Cycle Clipboard Ring - Secrets of Visual Studio

Least known but yet most powerful facility of Visual Studio is Cycle Clipboard Ring option.

What is Cycle Clipboard Ring?

Can you copy 10 different items in notepad and now paste all 10. You Can’t. L
What you can paste is only last copied item.

But visual studio allows you to paste last 16 copied items. J




In above image, I want to COPY all red arrow lines from bottom to top i.e. from line 132 to 108

Once copied, now I can paste all these items anywhere in Visual studio editors by using Cycle Clipboard Ring.

This option is available in Edit -> Cycle Clipboard Ring or Ctrl + Shift + V
Hold Ctrl + Shift and Press V again and again [Don’t release Ctrl + Shift]




It’s like a circular stack, after pasting last item you should get first item again as below

Please leave your comments or share this tip if it’s useful for you.

Wednesday, July 31, 2013

How to visit any particular line of code in Visual Studio

If there are lots of lines of code in a single code file and your colleagues told you to look piece of code at particular line number or any error occurred at specific line number.

How do you visit to that line of code?

By just scrolling ... that’s history

Solution :->

Some couple of handy ways to visit to particular line number in Visual studio
·         You can display line number at left side of code editor from Tools -> Options -> Text Editor -> All Languages -> Enabled Line numbers option. It should display line numbers in code editor as shown below




·         Visual Studio always display line number , column number and character position of cursor in status bar of visual studio as shown in above image

·         You also have facility to directly visit to any line number from Edit -> Go To... or press Ctrl + G as shown below


·         Use bookmarks to directly visit any particular line numbers

·         Use scroll bar to visit to particular line

·         Use keyboard Page Up or Page Down button

·         Use UP or DOWN arrow keys to navigate


Please leave your comments or share this tip if it’s useful for you.

Tuesday, July 30, 2013

How to get distinct values from column in Excel

If you have repetitive entries in excel column as below


How to get distinct values from column in Excel sheet.


Solution:-

Select column and click on Data -> Remove Duplicates
You should get output as below




Please leave your comment if it’s useful for you.

Monday, July 29, 2013

How to show more than 10 projects in Visual Studio recent project list

During working in Visual Studio (VS), we can view most recently used project in "Recent Projects" list.
However VS shows only 10 recent projects.

If we are working on multiple projects then how to show more than 10 projects in recent project list?

Solution:-

Open Visual Studio -> Go to Tools -> Options -> General -> modify value of "items shown in recently used lists".

Generally I make it 20.


Please leave your comments if it’s useful for you.

Thursday, July 25, 2013

Maximum request length exceeded

If you are getting error in Asp.Net as “System.Web.HttpException: Maximum request length exceeded This type of error mostly occurred when we are using File Upload functionality.

Due to increase in content lenth of request from the its dafult value then ASP.NET engine fires this error.


Solution: -

Open web.config file and set “maxRequestLength” key to more than the size of file.
The default size of “maxRequestLength” is 4096 KB (4 MB).
Value must be specified in KB as below

<httpRuntime maxRequestLength="10240"></httpRuntime>



10240 means 10 MB. (10 x 1024) - You can increase this up to 4 GB.