The official site of Four13 Designs offering downloads for DesktopX.
Error: Mismatched Type
Published on May 15, 2005 By Sranshaft In DesktopX
Tried using the code here:

[code]

134 If Len(track) > TrackChar Then
135 Track = Left(Track, TrackChar)
136 DesktopX.Object("widget_itunes_track").Text = Track

[/code]

The code keeps coming back as an error though

Type Mismatch: "Left"
Line: 135
Code: (not available)

What could be causing this error? I checked the VBScript website at Microsoft and I am using the function correctly.

Any ideas?

Comments
on May 15, 2005
I'd think it's an invalid argument being passed on to Left. Debug the values that's being passed on. Try something like: Script.MsgBox "Len: " & Len(Track) & vbcrlf & "TrackChar: " & TrackChar. If TrackChar returns a number outside the length of "Track" or a non-numeric value you have to go through your preceding code.
on May 15, 2005
Thankyou thomassen for your reply. The problem seems to be with the Left function itself. TrackChar returns a numeric value and I've tried hard-coding the number as well with no results. The funny thing is both the Right and Mid function work fine.

Any other ideas???
on May 15, 2005
Hmm sometimes I had to do this:

var=var-0

then var is now a numeric value and not a string. No idea why it does that, however!
on May 16, 2005
var=var-0

Or use var=CInt(var) (assuming you are using an Integer) This ensures you get an Integer object. Use CSng or CDbl if you need a floating number.

Sranshaft:
So the values passed on to the Left function is 0 or more and less than the length of the Track string? Left will return an error if the length agrument is less than 0 or higher than the numbers of characters in the string being processed.