I wonder how the paint company has managed to keep the cost of a gallon of paint steady amidst all of these rising prices…
Oh wait, now I get it.
E-Tech update: They have once and for all denied my appeal for a refund on the Sony replacement keyboard. Maybe I should have done a more big budget picture to demonstrate instead of what was done. (99 cents total were spent on Blue Harvest, I needed some chalk to write on the clapperboard and there were no kids around to beat up so that I could steal some.)
It has been a while since I posted something, and so when I was cleaning up the files from an older computer last night and stumbled on this beauty that I screen captured way back on August 19, 2004, I figured I should share…
Don’t bother going to their web site and checking, Dell fixed it pretty quickly, just in case you were wondering. Oh, and no word yet from E-Tech eStore regarding my appeal.
For many years, I faithfully used a Sony Vaio VGN-FS742/W notebook computer. This computer was an absolute workhorse, and I never had a problem with it, despite using it heavily for software development as well as the usual e-mail and web surfing activities.
After I let my brother and his family use the computer, an unfortunate incident occurred that involved the cosmetic destruction of the B key on the keyboard. The key worked, but the tabs that held the platform that the keycap sits on broke off, so the B key stuck out higher than the rest of the keys on the keyboard. Unsightly, yes, but still functional.
Alas, my brother had to have a functional and flat keyboard, so I began the process of looking to find a replacement keyboard for a computer that was 5+ years old. The Sony part number for this keyboard is 147915321, and it must be the same keyboard on all VGN-FS series Vaio notebooks.
The first thing that I found was that I was more than likely going to have to buy a used keyboard and hope that it worked just fine. So I ordered one from the E-Tech eStore. The keyboard arrived well packaged, and after I installed it, I tested every single key on the keyboard and found that all of the keys worked except for the V key.
At this point, I should have requested an RMA for a refund, but I mistakenly requested a replacement. After sending the first keyboard back and getting the second keyboard, the situation got worse, as on the 2nd keyboard, quite a few more keys were not working. And of course, at this point my return request for a refund was rejected, as E-Tech is claiming that their keyboards are all tested, and that I check my equipment for failure.
So, as a response, I created this little rant video showing that my equipment is fine:
As I said in the video, I cannot see how they could have tested the keyboard fully, since my hardware seems to work fine with my old keyboard with the B key tabs broken. I am guessing that their replacement keyboards are all pulls from computers that are dropped off at the computer recycling, and for the particular keyboards that I received, the reason the computer was at the recycling center was that some of the keys stopped working.
By the way, congrats to the Ohio Bobcats. Big win last night.
UPDATE: I still haven’t heard anything from E-Tech eStore (if you click on the link, try not to get creeped out by the ad on the right with the weirdly moving eyes) regarding my appeal of their RMA request denial. Thanks to Tai Tran (eBay seller ID ttni) who came through with a perfectly working replacement keyboard.
In order to send stuff to the printer in VB.NET, it is not quite as simple as dealing with the Printer object as in VB6. There are a couple of extra steps involved. Here is what I found, along with some helper methods that you might find useful.
On the form you want to print from, pull up the Toolbox and add a PrintDocument, a PrintDialog, and a Button, set the Document property of the PrintDialog to point to the PrintDocument you just created, and in the button’s Click event, insert the following code:
PrivateSub butPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles butPrint.ClickIf PrintDialog1.ShowDialog()= Windows.Forms.DialogResult.OKThen
PrintDocument1.DefaultPageSettings.Landscape=True
PrintDocument1.Print()EndIfEndSubPrivateSub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs)Handles PrintDocument1.PrintPage
PrintTestPage(e.Graphics, PrintDocument1)EndSub
The Print method call in the button click event then fires the PrintDocument PrintPage event. Notice that I have set the default page settings to landscape. Don’t forget to wire the PrintDialog Document property to your PrintDocument, otherwise if you change the printer to print to in the print dialog, the document will still go to the default printer.
The PrintTestPage method is just something simple that I put together to make sure that the coordinates and justifications are all working fine. Here is that code:
Sub PrintTestPage(ByVal g As System.Drawing.Graphics, ByVal doc As PrintDocument)Dim x, y AsIntegerFor x =0To100Step10For y =0To100Step10
PrintAtLocationWithColor(g, doc, x.ToString+", "+ y.ToString, x, y, _
If(x =0, "L", If(x =100, "R", "C")), If(y =0, "T", If(y =100, "B", "C")), _
"Arial", 8, True, Brushes.Red)NextNext
PrintRectangle(g, doc, 0, 0, 100, 100)
PrintRectangle(g, doc, 10, 10, 80, 80)
PrintRectangle(g, doc, 20, 20, 60, 60)
PrintRectangle(g, doc, 30, 30, 40, 40)
PrintRectangle(g, doc, 40, 40, 20, 20)EndSub
The two methods called here, PrintAtLocationWithColor and PrintRectangle, are shown here:
Sub PrintAtLocationWithColor(ByVal pg As Graphics, ByVal pd As PrintDocument, ByVal s AsString, _
ByVal xPosition As Single, ByVal yPosition As Single, _
ByVal justification AsString, ByVal verticalJustification AsString, _
ByVal fontFace AsString, ByVal fontSize As Single, _
ByVal fontBold AsBoolean, ByVal theColor As Brush)Dim w, h As Single
Dim x, y As Single
Dim f As Font
Dim sty As FontStyle
sty = FontStyle.RegularIf fontBold Then sty = sty + FontStyle.BoldIf fontSize < 1Then fontSize =8.0
f =New Font(fontFace, fontSize, sty)If pd.DefaultPageSettings.LandscapeThen
x = xPosition /100*(pd.DefaultPageSettings.PrintableArea.Height)
y = yPosition /100*(pd.DefaultPageSettings.PrintableArea.Width)Else
x = xPosition /100*(pd.DefaultPageSettings.PrintableArea.Width)
y = yPosition /100*(pd.DefaultPageSettings.PrintableArea.Height)EndIf
w = pg.MeasureString(s, f).Width
h = pg.MeasureString(s, f).HeightIfLeft(UCase(justification), 1)="C"Then
x = x - w /2EndIfIfLeft(UCase(justification), 1)="R"Then
x = x - w
EndIfIfLeft(UCase(verticalJustification), 1)="C"Then
y = y - h /2EndIfIfLeft(UCase(verticalJustification), 1)="B"Then
y = y - h
EndIf
pg.DrawString(s, f, theColor, x, y)EndSubSub PrintRectangle(ByVal pg As Graphics, ByVal pd As PrintDocument, ByVal xPosition As Single, ByVal yPosition As Single, _
ByValwidthAs Single, ByVal height As Single)Dim w, h As Single
Dim x, y As Single
If pd.DefaultPageSettings.LandscapeThen
x = xPosition /100*(pd.DefaultPageSettings.PrintableArea.Height)
y = yPosition /100*(pd.DefaultPageSettings.PrintableArea.Width)
w =width/100*(pd.DefaultPageSettings.PrintableArea.Height)
h = height /100*(pd.DefaultPageSettings.PrintableArea.Width)Else
x = xPosition /100*(pd.DefaultPageSettings.PrintableArea.Width)
y = yPosition /100*(pd.DefaultPageSettings.PrintableArea.Height)
w =width/100*(pd.DefaultPageSettings.PrintableArea.Width)
h = height /100*(pd.DefaultPageSettings.PrintableArea.Height)EndIf
pg.DrawRectangle(Pens.Black, x, y, w, h)EndSub
All of the positioning and size parameters of these methods are percentages across and down the page, which I find much easier to deal with than absolute or printer specific positioning. This makes it dead simple to scale the reports to any page size I want to use.
For some reason, my Sandisk Sansa e250 MP3 player was stubbornly refusing to acknowledge the music that I was copying to it. I tried just about everything I could think of short of formatting the device to get it to see my folders in the Music folder. My device has the latest version 1 firmware upgrade, and I have tried to use both MSC and MTP mode to copy folders to the device, all to no avail.
Finally, I found out that I could force the device to do a database rebuild by doing the following steps, which should work on any Sansa e200 series MP3 player with the version 1 firmware: (WARNING: Please do not do this if you are worried about making your device inoperable. There is always a risk that this will happen when you start futzing with the system files.)
Go into the Settings screen and scroll to USB mode, and set it to MSC
Connect the device to the computer
Once the device mounts as a drive on your computer, browse to the device, look for the System folder, and the Data folder in that folder
Delete the file called PP5000.DAT
Disconnect the device
Once you disconnect, the device will restart, and it should refresh the database. If you prefer MTP mode, make sure to go back into the settings to change it back.
I think that Google might have the Gmail phishing filter set just a tad too strong. I was in my Gmail account this morning and accidentally clicked on the very first message I got in the account, which is of course the introductory e-mail that describes how to switch your existing e-mail over to Gmail. Here is what I saw:
In converting some legacy VB6 code to VB.NET, I noticed that there was a lot of use of the Format function in the code to convert numbers to strings. This makes sense as Format was pretty much the only game in town in VB6.
However, in .NET, they introduced a handy-dandy .ToString() method that, on the surface, seems to do much the same thing as the Format function. I have been able to use them pretty much interchangeably with the desired results coming out every time.
I started to wonder which way was faster. Since I am a big proponent of empirical knowledge instead of just trying to get the theoretical story behind the two ways to do this, I rolled together this quick VB.NET console application:
Imports System.Text
Module Module1
Sub Main()
Dim i AsIntegerDim r AsRandom = NewRandom()
Dim t AsDouble
System.Console.WriteLine("10,000,000 Formats")
Dim sb1 AsNew stringbuilder
t = Timer
For i = 1 To 10000000
sb1.Append(Format(r.NextDouble * 100.0, "###0.00 "))
Next
System.Console.WriteLine("Seconds elapsed: " + (Timer - t).ToString("#######0.00"))
System.Console.WriteLine("Length of string builder: " + sb1.Length.ToString())
System.Console.WriteLine()
System.Console.WriteLine("10,000,000 ToStrings")
Dim sb2 AsNew StringBuilder
t = Timer
For i = 1 To 10000000
sb2.Append((r.NextDouble * 100.0).ToString("###0.00 "))
Next
System.Console.WriteLine("Seconds elapsed: " + (Timer - t).ToString("#######0.00"))
System.Console.WriteLine("Length of string builder: " + sb2.Length.ToString())
System.Console.WriteLine()
System.Console.WriteLine("Press any key to end the program ")
System.Console.ReadKey()
EndSubEnd Module
And here are the results:
As you can see, the ToString method is about 15% faster when doing 10 million calls with random numbers.
I can’t believe that, with all of the trips that I have made to the Bay Area, that I never heard of this place or stumbled upon it by accident. I so want to go there now to look for a copy of Microsoft Bob. Or maybe I should try to sell my copy of Microsoft Dogs.
It has apparently been a long time since I had to do any kind of reading and writing from the console in C.
I was trying to work through the Minesweeper problem on the UVa Online Judge site, and my submissions kept failing with a “Runtime error”, with no explanation given as to the source of the problem. Of course, everything was working swimmingly when I was trying to run through the code as a command line application in Xcode on my Mac. Some investigation into this led me to pad my arrays and strings so that there was no chance of an array index going into areas they were not supposed to, but it was still failing.
I finally discovered the problem was that I had used an int variable in my code, but a %i instead of a %d in the scanf format string. As soon as I switched that over, the “Runtime error” went away. And I was able to move on to the “What do you mean ‘Wrong answer’???” part of my evening.