 |
JLRodgers Level: Moderator
 Registered: 04-04-2002 Posts: 1616
|
Re: Data Type Mismatch - What does it mean..??
You're putting ' around the number, making it a string, just remove the '
____________________________
Everywhere's Local (classifieds, job postings, & more for everycity in the world - user entered)
|
|
19-05-2003 at 10:25 PM |
|
|
~Bean~ Level: VB Guru

 Registered: 07-04-2003 Posts: 488
|
Re: Data Type Mismatch - What does it mean..??
Since this is the second question I've seen raised regarding this error (in the past week) I thought I would post an explanation for some folks. There are times when this error can appear for strange reasons, but for the most part you get this error when you have assigned a variable a value that doesn't match the type you have defined for that variable...eg.,
'Simple Type Mismatch Error
Dim x As Integer 'Declare the Variable, and Define it's Type as an INTEGER
x = "String" 'Attempt to Assign the Variable a STRING Value
|
However...this is acceptable...
'Type match
Dim x As Integer
x = 1 'This is OK
x=1.1111111111 'This is ALSO OK, though x will still only equal 1 (an integer)
|
As I mentioned, this error can arise from a number of diff possibilities, but this is most common, and indeed, its also a variation of what Kenny ran into. And so the name of the error is actually quite descriptive of the error itself...you could say they "match"...(tee-hee)
FYI:
quote: From VB Documentation:
Type mismatch
-The variable or property isn't of the correct type. For example, a variable that requires an integer value can't accept a string value unless the whole string can be recognized as an integer.
Try to make assignments only between compatibledata types. For example, an Integer can always be assigned to a Long, a Single can always be assigned to a Double, and any type (except auser-defined type) can be assigned to a Variant.
-An object was passed to aprocedure that is expecting a single property or value.
Pass the appropriate single property or call a method appropriate to the object.
-A module or project name was used where an expression was expected, for example:
Debug.Print MyModule
Specify an expression that can be displayed.
-You attempted to mix traditional Basic error handling with Variant values having the Error subtype (10, vbError), for example:
Error CVErr(n)
To regenerate an error, you must map it to an intrinsic Visual Basic or a user-defined error, and then generate that error.
A CVErr value can't be converted to Date. For example:
MyVar = CDate(CVErr(9))
Use a Select Case statement or some similar construct to map the return of CVErr to such a value.
-At run time, this error typically indicates that a Variant used in an expression has an incorrect subtype, or a Variant containing anarray appears in a Print # statement.
To print arrays, create a loop that displays each element individually.
____________________________
Eggheads unite! You have nothing to lose but your yolks.
|
|
20-05-2003 at 02:49 PM |
|
|
|
|
 |
 |