469,923 Members | 1,745 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,923 developers. It's quick & easy.

VBScrip Type Mismatch Error

I'm getting a type mismatch error on the mid(strRecord,1,1)="H" line. I
used to do this all of the time, but I haven't done any VBScript for
awhile, so I'm sure I'm forgetting something.

While not objResults.EOF
strRecord=String( 333 ,32 )
IF TicketID<>objResults.Fields("ticket").Value then
Mid(strRecord,1,1)="H"
mid(strRecord,2,5)=objResults.Fields("cust").Value 'cust
mid(strRecord,7,30)=objResults.Fields("ship1").Val ue 'ship1
mid(strRecord,37,30)=objResults.Fields("ship2").Va lue 'ship2
mid(strRecord,67,30)=objResults.Fields("ship3").Va lue 'ship3
else
mid(strRecord,1,1)="D"
END IF
objStream.WriteLine(strRecord)
TicketID=objResults.Fields("ticket").Value
objResults.Movenext
Wend

Jul 23 '05 #1
2 2543
I think you have messed up with the Mid function. Mid return a string
and it cannot be used the way you are using it. I would approach the
whole script differently:

While not objResults.EOF
IF TicketID<>objResults.Fields("t*icket").Value then
strRecord = "H"
strRecord = strRecord +
objResults.*Fields("cust").Value 'cust
strRecord = strRecord +
objResults*.Fields("ship1").Value 'ship1
strRecord = strRecord +
objResult*s.Fields("ship2").Value 'ship2
strRecord = strRecord +
objResult*s.Fields("ship3").Value 'ship3
strRecord = strRecord + Space(333 -
Len(strRecord))
else
strRecord="D"
strRecord = strRecord + Space(333 -
Len(strRecord))
END IF
objStream.WriteLine(strRecord)
TicketID=objResults.Fields("ti*cket").Value
objResults.Movenext
Wend

Jul 23 '05 #2
you can only use mid(string,1,1) = "h" in VBA + VB6 etc

you can not use this construct in VBScript

Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Arun Wadhawan | last post: by
1 post views Thread by LJgrnl | last post: by
reply views Thread by news.paradise.net.nz | last post: by
1 post views Thread by amitbadgi | last post: by
3 posts views Thread by amitbadgi | last post: by
1 post views Thread by Brett | last post: by
6 posts views Thread by Howard Kaikow | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.