MAN for .NET

5. October 2007 03:32 by Mrojas in General  //  Tags: , , , ,   //   Comments (0)
Microsoft recently published the MTPS Content Service

In brief, the MTPS Content Services are a set of
web services for exposing the content in
Microsoft/TechNet Publishing System (MTPS).


And Craig Andera, has develop a swift nice tool
called msdnman that you use from the command line to
get information from the MSDN

Also I recommend you to see this cool video of a Human LCD that Hugo sent me

Comparison Tool for Windows

4. October 2007 11:53 by Mrojas in General  //  Tags:   //   Comments (0)
If you need a good and FREE comparison tool
I recommend WinMerge

Input Line Too Long

3. October 2007 09:35 by Mrojas in General  //  Tags: ,   //   Comments (0)
I was trying to compile a C++ Project in Visual Studio
and this project has a post-build step that executes
some batch statements.

And succendly from one day to the other the project failed
and the only message I had was
The input line is too long


After some googling I found that this error is displayed
when the command line in the command prompt
exceeds the maximum number of characters.
(Something quite obvious jeje)

The bottom line was that recenlty I had installed
some software and my PATH variable became TOO long
I fixed it by creating a new environment variable
called EXTRA_PATH where I put some references to
Some big paths and then changed my PATH variable
replacing all those long variables for %EXTRA_PATH%.

And problem solved!

VB6 References Explorer

1. October 2007 11:22 by Mrojas in General  //  Tags:   //   Comments (0)
I recently found this decent tool called VB6 Reference Explorer.
It even comes with source code.

This tool will show a list of the references for a set of projects in your path.




Here at Artinsoft, some colleagues have develop
some tools that perform even more exhaustive
project analisys like CreateObject dependencies
and others. Maybe I'll post something about those
tools in the future

VB6 Printer Object and PrintForm migration

1. October 2007 10:55 by Mrojas in General  //  Tags: , , ,   //   Comments (0)

If you ever had any problems while migrating from VB6 Printer Object or the PrintForm functionality
we have goods news for you the Microsoft Visual Basic 2005 Power Pack 2.0.
Our version of the Visual Basic Companion already provides and extended migration of the Printer Object,
and we're now updating it to use this new implementation. This Printer Compatibility Library makes it a
breeze to migrate Printer Functionality.

This is the description of the PowerPack:

"The new Line and Shape controls included in this version of the Visual Basic 2005 Power Packs are
a set of three graphical controls that enable you to draw lines, ovals, and rectangles on forms and
containers at design time making it much easier to enhance the look of your user interface.
These new shape controls also provide events such as click and double-click allowing developers
to respond and interact with end users.

The Printer Compatibility Library allows projects that used the Printer and Printers Collection in Visual Basic 6.0
 to be upgraded without having to re-write your printing logic. By simply adding a reference to the library, declaring a
Printer and making a few minor syntax changes, your project will be able to print using the Printers collection
and Printer object as it did in Visual Basic 6.0. This version adds a new Write method to the Printer object which
allows you to print text without a forced carriage return similar to the semicolon syntax used by Print method in Visual Basic 6.0.

The PrintForm component is designed to bring back the ability to easily print a Windows Form.
With this the new PrintForm component you can once again layout the Windows Form exactly as
you want it and allow your users to print the form as a quick report."

You can download the PowerPack from here

NOTE: there's is another link that only includes the Printer Library but MS recommends to download the PowerPack
because minor upgrades and fixes will be done on the PowerPack distribution

 

IE7 Print shrink to fit problem

29. September 2007 17:22 by Mrojas in General  //  Tags: , , ,   //   Comments (0)
IE7 has an interesting bug...
Someone decided to change the printing default
to "Shrink to Fit".This is supposed to be good
because it will make printing of web pages better
but it affects several applications develop for
IE, for example if you are using the Web Access
to your Exchange server, or if you have an application
that prints on a page that is not a letter size page


Well a guy from a forum found an excellent solution.

The only problem is that he refers a hot fix,
but if you have problems with that hotfix, then
do the following:

1. Go to windowsupdate.microsoft.com

2. Make sure you have the following updates:

** Security Update for Internet Explorer 7 for Windows XP (KB938127)
** Cumulative Security Update for Internet Explorer 7 for Windows XP (KB937143)

And then run the following in the command prompt:
reg add "HKLM\SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_STF_Scale_Min" /v iexplore.exe /t REG_DWORD /d 100 /f

Remove unused references VB6

28. September 2007 11:33 by Mrojas in General  //  Tags: , , , , , , , ,   //   Comments (0)

As part of the VB Companion Development group, my day to day includes
migrating several project from different clients, to develop custom mappings
and custom functionality for their migration needs or to add new features
for the next VB Companion version.

A long part of the initialization in the migration process consists of the load and
analysis of the COM references indicated in the .VBP project file.

Sometimes I have notice that there are several references that are never used.
Removing these references will provide a great save in time because the migration will
not have to incur in any time for TypeLib and TypeInfo extraction.

I look for a tool that let me get rid of the VB6 unused referencences but I found none.
So I decided to create one myself. And I created the VB6 Project References Cleaner Addin

The concept of the tool is simple, someone from a group posted the idea I just implemented.
The addin goes thru all the references and one by one tries to remove it.
And then compiles the project. It the project compiles,then the reference was not neccesary.
If you mark the remove option the tool will remove the references for you.

This tool will NOT SAVE the project file. You decide if you what to save it.

I'm attaching the source code and the dll. To used it just take the VB6References.dll and run:

  regsvr32 VB6References.dll
After that the tool will appear in the Addins menu in VB6 SOURCE CODE and BINARIES

 

 

 

VB6 API calls to .NET

27. September 2007 10:06 by Mrojas in General  //  Tags: , , , ,   //   Comments (0)
Every SERIOUS VB6 application, ended up requiring
that you import some functionality from the windows API or another DLL.
However if you were looking for a .NET equivalent and
google did not take you to the right page,
there is a document (a little old I might say) called
Microsoft Win32 to Microsoft .NET Framework API Map

I remember a couple of other pages that were even more complete,
but right know I can only remember http://pinvoke.net that gives some info about APIs

2008 is the final warning to move VB6 applications to .NET

27. September 2007 06:51 by Fzoufaly in General  //  Tags:   //   Comments (0)

Rob Helm, director of research at Directions on Microsoft, recently answered the question "Do the new releases of the Microsoft platform have an impact on the issue of upgrading applications from Visual Basic 6 to Visual Basic .NET?" with the quote that is the title of this post.

He said that the new platform updates really do not have an impact and that you should not wait any longer to move. He emphasized that after the end of support date for VB6 the support will only be through a special support contract with Microsoft that typically is "very onerous" and increasing every year.

Additionally, Rob Helm mentioned something that I had not noticed. Did you know the name of Visual Basic .NET is now officially only "Visual Basic"? Definetely another sign pointing at the future!

Coldfusion8 html cfgrid problem

26. September 2007 09:21 by Mrojas in General  //  Tags:   //   Comments (0)
We had a problem with a cfgrid
Coldfusion8 introduces an HTML cfgrid that is AWESOME!!!
It is something you should use.
It is based in the also excellent library Ext But recently we were extruglying with it because when we tried to capture exceptions in the update functions nothing happened and it was terrible because a real life application NEEDS exception handling. My code was something like this:
First file was places.cfc

<cfcomponent output="false">


<cffunction name="getData" access="remote" output="false">
<cfargument name="page">
<cfargument name="pageSize">
<cfargument name="gridsortcolumn">
<cfargument name="gridsortdirection">
<cfquery name="team" datasource="cfdocexamples">
SELECT Emp_ID, FirstName, EMail
FROM Employees
<cfif gridsortcolumn neq "" or gridsortdirection neq "">
order by #gridsortcolumn# #gridsortdirection#
</cfif>
</cfquery>
<cfreturn QueryConvertForGrid(team, page, pageSize)>
</cffunction>

<cffunction name="editData" access="remote" output="false">
<cfargument name="gridaction">
<cfargument name="gridrow">
<cfargument name="gridchanged">

<cfif isStruct(gridrow) and isStruct(gridchanged)>
<cfif gridaction eq "U">
<cfset colname=structkeylist(gridchanged)>
<cfset value=structfind(gridchanged,#colname#)>
<cfquery name="team" datasource="cfdocexamples">
update employees set aaa<cfoutput>#colname#</cfoutput> =
'<cfoutput>#value#</cfoutput>'
where Emp_ID = <cfoutput>#gridrow.Emp_ID#</cfoutput>
</cfquery>
<cfelse>
<cfquery name="team" datasource="cfdocexamples">
delete from employees where emp_id = <cfoutput>#gridrow.Emp_ID#
</cfoutput>
</cfquery>
</cfif>
</cfif>
</cffunction>

</cfcomponent>
 

and the second file was grid2.cfm:

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">
function errorhandler(id,message) {
alert("Error while updating\n Error code: "+id+"\n Message: "+message);
}
</script>
</head>

<body>
<cfform name="form01">
<cfgrid format="html" name="grid01" pagesize=11
stripeRows=true stripeRowColor="gray"
bind="cfc:places.getData({cfgridpage},{cfgridpagesize},
{cfgridsortcolumn},{cfgridsortdirection})"
onerror="errorhandler"
delete="yes" selectmode="edit"
onchange="cfc:places.editData({cfgridaction},{cfgridrow},{cfgridchanged})">
<cfgridcolumn name="Emp_ID" display=true header="Employee ID"/>
<cfgridcolumn name="FirstName" display=true header="Name"/>
<cfgridcolumn name="Email" display=true header="Email"/>
</cfgrid>
</cfform>
</body>
</html>

And the problem where was it!!
It was not in any of those files it was in the application.cfm There was an onError handler. So it was commented out and everything work perfect! Well I just like to write down these little details so I don't make this silly things twice. I hope this can be of any help

SVN get files without the .svn directories

24. September 2007 16:19 by Mrojas in General  //  Tags: , ,   //   Comments (0)
I felt so stupid today. Because when for a couple of months,
every now and then, when someone asked me for a copy of the source code
I just made a copy of my src directory and then searched for the .svn* folder
and then I erased them,
until by mistake i found the EXPORT function.
I use SmartSVN and I was creating a new project
and then the light came to me :S
Well if it happens to you just remember there is a
svn export
command. This will get the code from the repository without all the nasty files.

Microsoft improves compatibility libraries for VB 6.0: Visual Basic 2005 Power Packs 2.0

24. September 2007 07:06 by Fzoufaly in General  //  Tags:   //   Comments (0)

Microsoft recently started to distribute a new version of the Visual Basic 2005 Power Packs. 

Link to Download details: Microsoft Visual Basic 2005 Power Packs 2.0

Notably, the routines that are included help with the automatic Upgrade/Migration of VB6 to .NET.  From the MSDN web site:

 

" Overview

The new Line and Shape controls included in this version of the Visual Basic 2005 Power Packs are a set of three graphical controls that enable you to draw lines, ovals, and rectangles on forms and containers at design time making it much easier to enhance the look of your user interface. These new shape controls also provide events such as click and double-click allowing developers to respond and interact with end users.
The Printer Compatibility Library allows projects that used the Printer and Printers Collection in Visual Basic 6.0 to be upgraded without having to re-write your printing logic. By simply adding a reference to the library, declaring a Printer and making a few minor syntax changes, your project will be able to print using the Printers collection and Printer object as it did in Visual Basic 6.0. This version adds a new Write method to the Printer object which allows you to print text without a forced carriage return similar to the semicolon syntax used by Print method in Visual Basic 6.0.
The PrintForm component is designed to bring back the ability to easily print a Windows Form. With this the new PrintForm component you can once again layout the Windows Form exactly as you want it and allow your users to print the form as a quick report."

 

I'd like to relate this post with the one I did a few days ago related to performance (http://blogs.artinsoft.net/fzoufaly/archive/2007/0... ).  In the previous post I was arguing about the use of the VB6 Compat library from .NET applications.  Basically, I was arguing that the VB Compatibility library is written and distributed by Microsoft and therefore users should not be afraid to use it in their programs.  TThe same goes with the power pack Microsoft is now releasing.  The power pack contains a number of functions that are not directly addressed by the basic .NET framework but that are widely used and requested by VB programmers.  So what is the right solution?  Well, program them in .NET!!!  I mean, is there another way to provide functionality that is not by programming it?  Again, don't be afraid of using these routines more than you would be of any control you use in your app.  And also, do not worry about the performance hit!!

Twips and .NET

20. September 2007 04:46 by Mrojas in General  //  Tags: , , ,   //   Comments (0)

In the VB world previous to .NET a concept you probably had to deal with was TWIPS.

What were Twips? Well if you do not remember those happy VB6 times, let me refresh your memory:

Twips are screen-independent units to ensure that the proportion of screen elements are the same on all display systems.
A twip is defined as being 1/1440 of an inch.


A Pixel is a screen-dependent unit, standing for 'picture element'.
A pixel is a dot that represents the smallest graphical measurement on a screen.

In .NET everything is pixels. So if you migrated something from VB6 using the Upgrade Wizard you might found several expressions like:

VB6.TwipsToPixelsX(ctrl.Left)

or VB6.PixelsToTwipsY(ctrl.Height)

There is an X and a Y version of this function, because the conversion factor is not the same for both axis.

Sadly you can even found some expressions like:

VB6.TwipsToPixelsX(VB6.PixelsToTwipsX(ctrl.Left))

In a strict sense there could be minor differences because of the conversion factors. But in it seams that things like that can be removed because all controls Bound properties like Left, Top, Bottom, Right are in pixels. So why will you convert your pixels units to Twips units to then convert them back to Pixels if they where already in Pixels????

Also you can find something like:

VB6.TwipsToPixelsX(ctrl.Left + ctrl.Width + 30) which should be something like:

ctrl.Left + ctrl.Width  + VB6.TwipsToPixelsX(30)

If you have an application migrated with the Upgrade Wizard you can use some regular expressions to improve those expressions. If the conversion is something like:

VB6.TwipsToPixelsY(VB6.PixelsToTwipsX(ctrl.Left)) then be careful because conversion factor might produce a different value, due to the change of axis.

 

 

jeje Or you can uset the VBCompanion, the extensible version of the Upgrade Wizard!!!

 

Will your VB6 application continue to work on Vista?

19. September 2007 05:19 by Fzoufaly in General  //  Tags:   //   Comments (0)

Microsoft is committed to support the vb6 runtime environment on Vista. However they will not continue to support the IDE: the development environment is not officially supported by Microsoft on Vista.

More detailed information can be found at: VBRUN and ftponline

Additionally, do not forget to also verify the support of your third party controls. Are they being supported by their manufacturer?

Many companies have already moved or are in the process to upgrade their Visual Basic Applications to .NET. However, many others are procrastinating their decision. Which type are you? Dont'you think it is time to move yet? What are you waiting for?

Performance of migrated VB6 applications to .NET

13. September 2007 10:34 by Fzoufaly in General  //  Tags:   //   Comments (0)

A common question when upgrading VB6 applications to .NET is regarding the performance of the application.

The short answer is that the migrated app typically performs as good as the original application. Let's dive into a couple of common issues that customers typically worry about:

1) the use of the VB6 compatibility classes in .NET: First of all, I believe this is a very bad namespace name! Everytime you hear compatibility library you think about performance. However, in this case, all the classes in the compatibility library are implemented in .NET. They are included just to simplify the maintainability of the code. The functionality that they provide is not directly provided by .NET, therefore, the correct way of implementing it is to just program it in .NET which is exactly what the compat classes do. NO performance penalty here! In addition, these classes are part of the .NET framework, thay are supported by Microsoft and they will continue to be supported for the forseable future! If there is a function in there that you want to use it, just do it!

2) COM Interop: The VB Upgrade Wizard generates primary assemblies for the COM component that are referenced from VB6. This is of course the fastest way to communicate with them from .NET. Now, typically, COM components are black boxes that presumably execute non trivial functionality. This means that typically the time spent by the execution of the COM component is orders of magnitude larger than the time spent in the calling of the component from .NET. Therefore the performance impact is negligible. This is not true of course if the COM interface is very chatty as you will have to go through the primary assembly overhead many times.

The reason to eliminate COM interop is normally not one of performance. You want to eliminate COM components for maintainability reasons, for deployment reasons or to take advantage of newer versions of the components. If you just want to maintain the same functionality COM interop does not present a performance situation.

In summary and reinforcing the introductory statement a converted application from Visual Basic 6 to .NET typically performs in the same way as the original one.

Have you had a different experience? Let me know!

Casting in .NET

13. September 2007 04:20 by Mrojas in General  //  Tags: , , ,   //   Comments (0)

.NET has a more strict typing than VB6
So you must check in some circumstances if your object implements an interface or not.

So I had used the as and is operators in C# but I did not know how to do that.
I did I little research and I discovered some things about casting operators for VB.NET

 

Operator Example Observations
CType Dim testNumber As Long = 1000
' The following line of code sets testNewType to 1000.0.
Dim testNewType As Single = CType(testNumber, Single)
 
Throws InvalidCastException or OverflowException

It could be less eficient due to VB.Net helper routines.

This is a Narrowing and Widening operator.

It can be overloaded

Public Structure digit
Private dig As Byte
    Public Sub New(ByVal b As Byte)
        If (b OrElse b > 9) Then Throw New _
            System.ArgumentException("Argument outside range for Byte")
        Me.dig = b
    End Sub
    Public Shared Widening Operator CType(ByVal d As digit) As Byte
        Return d.dig
    End Operator
    Public Shared Narrowing Operator CType(ByVal b As Byte) As digit
        Return New digit(b)
    End Operator
End Structure
 

 

DirectCast Dim f As New System.Windows.Forms.Form
Dim c As System.Windows.Forms.Control
' The following conversion succeeds.
c = DirectCast(f, System.Windows.Forms.Control)
 
Throws InvalidCastException. Is more efficient than CType because it does not depend on the Visual Basic helper runtime functions. It can even detect some errors as invalid casts during compile time
 

However it requires a relationship of inheritance of implementation
For example:

Dim q As Object = 2.37
Dim i As Integer = CType(q, Integer)
' The following conversion fails at run time
Dim j As Integer = DirectCast(q, Integer)
 

The run-time type of q is Double. CType succeeds because Double can be converted to Integer. However, the first DirectCast fails at run time because the run-time type of Double has no inheritance relationship with Integer, even though a conversion exists
 

TryCast     Dim obj As MyType = TryCast(obj, MyType)
    If obj Is Nothing Then
      ' Object could not be cast
 
  Else
     ' Object was casted

   End If
Throws no exceptions.


All this information has been taken from the MSDN site. This is just a quick summary. For more information see:

Type Conversion Functions
Conversion Functions (Visual Basic)

Widening and Narrowing Conversions
Implicit and Explicit Conversions
 

Good list of resources for VB6 Migrations from Microsoft's Peter Ty

12. September 2007 09:36 by Fzoufaly in General  //  Tags:   //   Comments (0)
Peter Ty assembled a good reference of links for Visual Basic 6 Upgardes to .NET. Enjoy! http://blogs.msdn.com/peterty/archive/2007/05/25/end-user-computing-foxpro-and-vb-migration.aspx

BANAMEX signs automatic VB6 migration contract with ArtinSoft

12. September 2007 08:31 by Fzoufaly in General  //  Tags:   //   Comments (0)

The launch of ArtinSoft's spanish web site (www.artinsoft.com.mx)  comes in synch with ArtinSoft's winning a very large contract to migrate over 170 Visual Basic applications at Banamex (a Citi Group subsidiary).  The applications will be fully updated and deployed by the bank in less than one year period.  This is a record time for such a large migration project: over 5 millions lines of code! 

Banamex performed extensive research on how to approach the VB6 support deadline.  Since the beginning of the evaluation process the internal debate was weather to automatically migrate or to rewrite the apps. 

They did a full assessment of their application portfolio and separeted the applications that were about to be retired and choose the applications that were functionally relevant to the business.   They observed that the chosen applications were simply performing all the business requirements they were supposed to perform, therefore no need to change them functionally!    The next realization was that a rewriting was definetely NOT the cost-effective way to solve the situation.  The estimated difference betweeb a rewrite and a migration was 5 to 1.

Banamex showed once more that if your application is performing and what you need to do is move to adopt .NET and all the benefits that come with it then the best way forward is through automatic upgrade.

 

Read more about the Banamex story at: the following links (some are in spanish):

 

La República: http://www.larepublica.net/app/cms/www/index.php?pk_articulo=854

El Financiero: www.elfinancierocr.com/edactual/tecnologia1231205.html

CIO América Latina: http://www.cioal.com/pcwla/cioaldocs.nsf/pages/8E66B81ACF8DB582852573500015F54B

Pergamino Virtual: http://www.pergaminovirtual.com.ar/revista/cgi-bin/hoy/archivos/2007/00001122.shtml

Business News Americas: http://bnamericas.com/login.jsp?idioma=I&urlJump=story.jsp$SEP$idioma$EQ$I$AMP$sector$EQ$1$AMP$noticia$EQ$406218

Yahoo! España: http://es.biz.yahoo.com/10092007/185/firma-costarricense-software-moderniza-sistemas-banamex.html

Yahoo! México: http://mx.news.yahoo.com/.../38/negocios-firma-costarricense-software-moderniza-sistemas-banamex.html&printer=1

La Prensa Gráfica: www.laprensagrafica.com/economia/870594.asp

TMCnet: http://www.tmcnet.com/usubmit/2007/09/10/2925480.htm

ArtinSoft soluciones de migracion automatica de software

12. September 2007 08:26 by Fzoufaly in General  //  Tags:   //   Comments (0)

 

Link to ArtinSoft – soluciones de migración de software

 

ArtinSoft just lunched its web site for the spanish market and specifically for the Mexican market. 

Fixed Len Strings in Visual Basic

7. September 2007 09:34 by Mrojas in General  //  Tags: , , ,   //   Comments (0)

This is a nostalgic note. Someone asked me, "hey, how do you make a fixed len string in VB6?"
As the computer geek that I am, that the kind of questions I like to be able to answer.
These are important questions like all those questions from the 80's rally:

The name of all the original thundercats...
The planet where Luck Skywalker went to learn with Yoda...
Which Star Trek character appear in ALL the episodes (yes it is Spock, Kirk is not in all of them)
Well, the thing is to define a fixed len string in VB6 you do something like:


Dim aString As String * 10

If you do something like:

aString = "Mau" ' aString ==> "Mau "

That's all

Fixed length strings are automatically filled with spaces to pad them to their fixed-length. How do you get rid of the extra spaces? Duh!!! with RTrim$ don't you remember

When a variable like aString is declared, it will be filled with Null characters until it is used.

And yes functions (RTrim$, LTrim$, and Mid$) will not trim Null characters, so be sure to assign it with an empty string "" immediately.


Ahh! and by the way when you translate that to .NET, .NET does not have a fixed len string so the easiest thing to do is use:
Microsoft.VisualBasic.Compatibility.VB6.FixedLengthString.

[C#]

using Microsoft.VisualBasic.Compatibility;
...

void foo()

{

VB6.FixedLengthString aString = VB6.FixedLengthString(10, "Mau");

}

 

Categories