Just an FYI, I strengthened the spam filters this morning on the blog to attempt to filter out some of the spam that had been creeping around the edges. Hopefully, no one will notice, but if you run into problems, do drop me a line using the comment form. Thanks!
Testing the filter: Is there any chance we’ll ever declare our arrays by capacity like normal people?
Thinking back to my option base days I’m failry sure that was my major reason for always picking base 1.
On a related note, kudos to whomever in 2.0 decided to make arrays with non-zero lower-bounds not castable to simple array types, I was enjoying playing with the System.Array methods to mess with my friends and was pleasantly suprised.
Since LINQ is adding to the multiparadigm-metamodel of VB, have you any cool ideas on the drawing board of plugging aspect-oriented programming into the language?
Last on my list of random SPAM filter testing:
At first I found the new aggressive C# intellisense irritating as hell. I still feel that way a little bit but I’m curious as to how you all didn’t jump on that – it seems like a very VBish thing.
Paul, are you the one that decided to not include the PRINTER.PRINT in VB?
Is it ever going to be put back in?
I need it, I’ll not be able to upgarde until that is back.
With all do respect, Carl, would it not be simpler and faster to simply implement a facade of the VB6 Printer object that adapts/forwards calls to the .NET methods.
Most of the members on the VB6 Printer object should be trivial to translate, especially if you are familiar with the .NET way of doing things. If not it should make a rewarding learning experience.
It is not my intention to trivialize the work that is upgrading/porting/migrating legacy code but I think at times we can be too dependant on Microsoft to hand us prepackaged code that we are perfectly capable of implementing ourselves. If you do a bit of research there may already be some VB6 adapter objects lying around GotDotNet or CodeProject.
I just don’t think that in this case this Alamo/"Hold my breath until my face turns blue" hold out is reasonable or productive.
Paul, Thanks for your reply.
I had worked with Greg Binkerd at MSDN and he sent me some samples on how to use the printer in .NET.
However I have some pre-printed forms that the image has a tendency to move on the page I have to make minor positioning changes to Print on the form and there is no easy way to do that in .NET.
If I had to move from VB6 to .NET my programs would have to be a total rewrite.
Here is a sample of some of my VB6 code and if I understand how the same thing is done in .Net is quite extensive.
Printer.FontBold = True
Printer.FontSize = 6
Printer.Print " ";
Printer.FontSize = 10
Printer.Print " ";
I will take a look at GotDotNet and CodeProject, maybe something there I can use.
Thanks again for your reply.
As you describe this code to me, Carl, it’s very reminescent of DirectX. The VB6 Printer object has a very state-machine pipeline feel and the .NET Printing is more object-based.
In the work that I’ve done when playing around with Managed DirectX from VB I found myself writing code to translate MDX to the object model (Impedence Mismatch’s cousin?).
Anyway in this case you’re trying to do the exact opposide abstraction and I’ll say from personal experience that the classes you write to make that really make it all worth it. When you take something as complicated as you’re saying and you encapsulate that to the point where the final client code looks simple that’s where the work truly pays off. It’s rewarding for me as a developer to have set all the pieces in play to make the "real code" cleaner and I think that if you look at your code and .NET and you write that facade layer that once you get the layer done a total rewrite won’t be necessary. And better still you’ll be able to reuse that code for future upgrade projects.
I know that right now it looks like a lot of work (a lot of upfront work). But that’s the point, if you look at LINQ or look at the .NET Framework, the code gen tools, etc, they’re all about these types of abstrations. It permeates what we we do. The goal of an abstraction is to take something complex and/or massive and make it look easy.
If you haven’t had enough of my motivational mumbo-jumbo I’d ask you to read this:
Good luck and take care!
"If I shoot myself in the foot, it hurts"
Yes, it is harder to position vertically or horizontally by printing spaces in .NET 1.0, 1.1 and 2.0. However, I have to ask, why do you want to do this?
I understand in VB 6, you had to do it this way. I’ve worked with VB since 1.0, I understand that. I understand, also, you need to be able to adjust where you are printing.
However, here is code to write a string 2 units left of the page start, and 2 units down from the page start. In my case, I use inches for units, but you can configure the object to use whatever:
ev.Graphics.DrawString("my string", bodyFont, bodyBrush, 2, 2, new StringFormat())
Now, if I am off by a tenth of an inch — the problem you say you are trying to address — I just change the number from 2 to 1.9 or to 2.1.
If I am really smart, I might use a StringDictionary, DataTable, DataSet or similar storage mechanism (or reflection — but for most applications, using the ADO.NET classes makes more sense) for the data coming into the routine. Then, I move my field list (to reference into that mechanism) into an external data source (such as an XML file), and in my loop, I look up the data to print, and I invoke drawstring with the saved position.
In this case, when I have to adjust the position, rather than recompiling my program to make things like up, I just go to the XML file, and adjust the number.
If you are familiar with any lottery games like Mega Million and PowerBall, they have a card with the number 1 through 56 and you can fill it out by putting an X on the card, which indicate the number you want.
My program will print an X over the numbers you want to play.
Unfortunately the image on the card is not in the same place all the time. There are positioning blocks on the card that the lottery terminal uses to adjust the image logical. I have no way to do that so, I have to move my X with some fine tuning using the printer.
If for instance I get some new cards and the image is more to the right, repositioning the X would be something like this.
If Box(index) = True Then
If CardCenter = False Then
For P = 1 To EndGap
For P = 1 To CenterEndGap
The user can make these adjustments and the positioning code is saved in a database.
By doing it this way I don’t have to recompile the program.
If you get this before Monday, have a happy Holladay.