Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Runtime error 13 Type Mismatch 1

Status
Not open for further replies.

vbprogrammer

Programmer
Jul 16, 2001
11
US
I only get this error when running the exe, not when running from within the VB environment. Can anyone tell me what would cause that? Also, how can I find the bad line of code? Using msgbox statements has failed to isolate it. Thanks.
 
If your code uses "early-binding" to automation objects such as Office then you can run into all sorts of triuble with users who have "back-level" versions and some with "up-level". MS warns to use "late-binding" especially with Access 2000 beacuse it has abandoned binary compatibility and DispID compatibility.
Code:
#If blnEarly then   ' Use IntelliSense during testing
    Dim objApp as Word.Application
    Dim objDoc as Word.Document
#Else
    Dim objApp As Object  ' Late Binding
    Dim objDoc as object
#End if
' Use CreateObject or GetObject
' As New can not be used in "late Binding"
put blnEarly=-1 in Command Line Arguments of Project / Properties / Make to use "early-binding" during testing.
 
I don't use any external packages other than True DB Grid by Component One. This problem only occurs with certain data. I am new to VB and I'm sure I'm doing something dumb in the code. It may very well be a data type mismatch; it's just that it is impossible to trace, especially since it only occurs in the exe. I have peppered the code with msgbox statements and they have failed to isolate the code. I use a grid on tabs(I have a tabbed dialog with three tabs). When I click on a certain tab(#3), I get this error. But the error actually occurs before the first line of the tab's clicked event!
 
This is probably a problem with communications between two data types. I always try to avoid using a Variant data type because I've ran into this problem myself. Also make sure you're not trying to push a Variant onto a Long or Integer, regardless if it fits. Use:

LongvariableX = val(VariantVariable)

not: LongvariableX = VariantVariable

Variants usually work good the other way around on strings:

StringVariable = VariantVariable mainly because Variants
variables can "read" long, integers and allows you to place representations of these into a string, but you can't do it the other way around, and -get this- it does treat these differently when being ran from the exe versus the environment.
Also try specifying every variable you are going to use and don't use Variants for numeric values, unless you can help it. Long variable are actually more memory efficient and make your code run faster than integers.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top