I figured out the problem with the routine/variables in the previous post. The issue was that StringToBreak was being passed as ByRef when it didn’t need to be. Changing it back to ByVal fixed things.
Basically, the calling routine was passing the same variable to StringToBreak and PreCompare. Because both were ByRef, this made those two variables actually aliases to the same memory location, and assigning PreCompare the results of Left() also made StringToBreak appear truncated.
Still no idea on the weirdness related to my custom collection becoming a normal collection when using Implements IEnumerable.
Here’s a head scratcher for the programmers in the bunch:
In this code fragment, assume pt is a valid integer pointing at an “=” sign in StringToBreak, and Comparison(i) is “=”
If pt > 0 Then
PostCompare = Trim(Mid(StringToBreak, pt + Len(Comparison(i))))
PreCompare = Trim(Left(StringToBreak, pt - 1))
CompareType = i
You’ll notice that I assign PostCompare before PreCompare in this fragment. Usually, I assign such things Pre then Post. However, I found that if I had the PreCompare *before* the PostCompare line, where it was originally, then PostCompare was always “”, an empty string. Making no other changes at all, other than swapping the order of the PostCompare and PreCompare lines as you see above, suddenly things were working again correctly, and providing the expected results. Bwah? I hope there aren’t more cases like this, because if Left() is setting the string it’s working on to the result, lots of badness will result (although that doesn’t generally seem to be the case).
And that’s not even the worst of what I encountered this week. The other day, I spent hours trying to figure out why my custom sorted item collection was acting exactly like a normal collection, instead of what it was supposed to do. Worse, it was working correctly for ItemsByType (each of which is an object in an element of another collection), but not for the full mixed-Items collection with all the stuff in it. Boggled. I finally just removed “Implements IEnumerable” and bam! suddenly it was working correctly everywhere.
Sometimes, programming is very annoying.
I’m learning more stuff in Visual Studio every day, but the best part is that I’m proficient enough with most of it now that I can actually get a lot done each day.
Today I learned how to instantiate new controls in code, add them to my form or container, and add event handlers to them. Not something I needed to do yet, but I’ll need it soon, and it’s even fairly easy, thanks to a helpful tutorial I found through the help system. (I still don’t care much for the help system, but we’re getting along better now.) This is easy enough that I don’t miss control arrays for this purpose, and the flexibility is better, but I still miss them for other things.
Unfortunately, I still have lots to learn once I get outside of the basic VB language features. For example, there are so many different types of collections now, and I need to learn the basics of them so that I know which one to use for what purpose. And then I need to implement custom versions of them, as necessary (which actually doesn’t appear hard at all).
There’s so much more for me to learn, but at least I know enough to generally work around what I haven’t figured out yet. Which is a lot. And which is sometimes incredibly frustrating. But I’m getting there.
I still keep getting incredibly frustrated trying to work with VB.Net. I can’t even figure out how to get my user control to appear in the toolbox once I’ve compiled it. It’s in the bin\release folder as it should be, but that’s about it. I can’t seem to find it in any of the selection options to add it into the toolbox.
I shoulda been a ditch digger.
Oh, also, on the Windows 7 front, I have printer issues. I got my HP LaserJet 4000 to install and work, but only with the PCL5 driver; the PCL6 driver and the PostScript driver both crash the printer, instead of printing to it. And my Xerox Phaser 6250 DP won’t print, although it appears to interact, since the status info in the printer gizmo appears correct. Still, any attempt to print results in nothing but a printer error in the queue. Bummers.
I’m working on my first custom/user control in VB.NET 2008, after completing my first draft of a simple, but complete, app the other day. The control I’m working on is pretty simple, basically an edit box for numerical/currency/rate information that I’ll be using throughout my work apps. I’ve got the basic data entry stuff in there, and now need to figure out how to interface with the properties window properly, and how to save and load property settings set at dev time.
I’m getting the hang of this a bit more each day, but still don’t like a lot of it (and am so over trying to read the docs in the crappy help system). I am looking forward to some of the extra power and features that should be at my disposal down the line, though.
One thing I really hate is the way the whole system forces me into a particular folder structure, and then apparently doesn’t let me change the names of some things if I change my mind on it later (which I actually do a lot). I’m usually calling a project one thing when I start, then change it to something else later. So far, I’ve found no way to change the name of my project folder once I’ve saved the project. And I’m sure I’ve just overlooked it, but I don’t seem to be able to just copy one component file from one project to a folder for another project, as the environment seems to insist it isn’t there. (And if I try renaming folders manually, VS insists the files are missing.)
I’m sure I’ll learn more of this stuff later, but damn, I miss working in the logical, understandable VB6 editor. (I know the VS editor is supposedly a huge hit with developers, and apparently has legions of fans, but I get tired of it deciding that it knows better than me what I want.)
Lately, I’ve been spending a lot of time working in VB.NET 2005, and I’m starting to get my brain trained to the new requirements for that language. I’d still like to hurt the programmers who C’d up my language, but I think I’ll be able to adjust given a bit more time with it. Funny story: I spent hours the other day trying to figure out why the heck I couldn’t get passing an array to a procedure to work. Was frustratated still when I stopped for the day. The next morning, I woke up and knew what the problem was: I was stuck in the VB6 mode of thinking, so I kept trying to pass the array with empty parens, when I should have just been passing the array’s name. Worked just fine after that.
GCA: GCA crossed 2900 downloads at e23 waaaaay back on June 11, 2008. Maybe I’ll start posting these closer to the event again now that I’ve got this WordPress thing goin’ on.