Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default data type problem XL9

Have come across a strange problem today with one of my customers.

In a .xla add-in I have in very much simplified code the following:

Sub test()

Dim l As Long
l = GiveString()
MsgBox l

End Sub


Function GiveString() As String

Dim s As String
s = "1"
GiveString = s

End Function

All this works fine on my 2 home PC's with XL11 and XL9.
With this one customer though in XL9 there is the error: Type mismatch.

Why would this be if it runs fine on the home machine with XL9?


RBS



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default data type problem XL9

I suspect the customer actually is experiencing this in xl97 (xl8). In xl97,
you would get that error.

--
Regards,
Tom Ogilvy


"RB Smissaert" wrote:

Have come across a strange problem today with one of my customers.

In a .xla add-in I have in very much simplified code the following:

Sub test()

Dim l As Long
l = GiveString()
MsgBox l

End Sub


Function GiveString() As String

Dim s As String
s = "1"
GiveString = s

End Function

All this works fine on my 2 home PC's with XL11 and XL9.
With this one customer though in XL9 there is the error: Type mismatch.

Why would this be if it runs fine on the home machine with XL9?


RBS




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default data type problem XL9

Just to add the example works fine in both my XL97 and XL2000, as does the
following in both versions

Dim n As Long
n = "123"

Regards,
Peter T


"Tom Ogilvy" wrote in message
...
I suspect the customer actually is experiencing this in xl97 (xl8). In

xl97,
you would get that error.

--
Regards,
Tom Ogilvy


"RB Smissaert" wrote:

Have come across a strange problem today with one of my customers.

In a .xla add-in I have in very much simplified code the following:

Sub test()

Dim l As Long
l = GiveString()
MsgBox l

End Sub


Function GiveString() As String

Dim s As String
s = "1"
GiveString = s

End Function

All this works fine on my 2 home PC's with XL11 and XL9.
With this one customer though in XL9 there is the error: Type mismatch.

Why would this be if it runs fine on the home machine with XL9?


RBS






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default data type problem XL9

Actually the non-simplified code is:

'error he
If Val(ReadINIValueL(strINIPath, _
"Add-in behaviour", _
"F2 for load add-in")) = 0 Then


Function ReadINIValueL(ByVal strINIPath As String, _
ByVal strHeader As String, _
ByVal strKey As String) As String

Dim buf As String * 256
Dim Length As Long

If Len(Dir(strINIPath)) = 0 Then
ReadINIValueL = "<no file"
Exit Function
End If

Length = GetPrivateProfileString(strHeader, _
strKey, _
"<no value", _
buf, _
Len(buf), _
strINIPath)

ReadINIValueL = Left(buf, Length)

End Function

And the result of the function was "1" and not "<no file" or "<no value"


RBS


"Peter T" <peter_t@discussions wrote in message
...
Just to add the example works fine in both my XL97 and XL2000, as does the
following in both versions

Dim n As Long
n = "123"

Regards,
Peter T


"Tom Ogilvy" wrote in message
...
I suspect the customer actually is experiencing this in xl97 (xl8). In

xl97,
you would get that error.

--
Regards,
Tom Ogilvy


"RB Smissaert" wrote:

Have come across a strange problem today with one of my customers.

In a .xla add-in I have in very much simplified code the following:

Sub test()

Dim l As Long
l = GiveString()
MsgBox l

End Sub


Function GiveString() As String

Dim s As String
s = "1"
GiveString = s

End Function

All this works fine on my 2 home PC's with XL11 and XL9.
With this one customer though in XL9 there is the error: Type mismatch.

Why would this be if it runs fine on the home machine with XL9?


RBS







  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default data type problem XL9

If I follow, effectively it does this (without the Val)

If "1" = 0 Then

again this works in both my XL97 & XL2k

Any missing references ?

Regards,
Peter T

"RB Smissaert" wrote in message
...
Actually the non-simplified code is:

'error he
If Val(ReadINIValueL(strINIPath, _
"Add-in behaviour", _
"F2 for load add-in")) = 0 Then


Function ReadINIValueL(ByVal strINIPath As String, _
ByVal strHeader As String, _
ByVal strKey As String) As String

Dim buf As String * 256
Dim Length As Long

If Len(Dir(strINIPath)) = 0 Then
ReadINIValueL = "<no file"
Exit Function
End If

Length = GetPrivateProfileString(strHeader, _
strKey, _
"<no value", _
buf, _
Len(buf), _
strINIPath)

ReadINIValueL = Left(buf, Length)

End Function

And the result of the function was "1" and not "<no file" or "<no value"


RBS


"Peter T" <peter_t@discussions wrote in message
...
Just to add the example works fine in both my XL97 and XL2000, as does

the
following in both versions

Dim n As Long
n = "123"

Regards,
Peter T


"Tom Ogilvy" wrote in message
...
I suspect the customer actually is experiencing this in xl97 (xl8). In

xl97,
you would get that error.

--
Regards,
Tom Ogilvy


"RB Smissaert" wrote:

Have come across a strange problem today with one of my customers.

In a .xla add-in I have in very much simplified code the following:

Sub test()

Dim l As Long
l = GiveString()
MsgBox l

End Sub


Function GiveString() As String

Dim s As String
s = "1"
GiveString = s

End Function

All this works fine on my 2 home PC's with XL11 and XL9.
With this one customer though in XL9 there is the error: Type

mismatch.

Why would this be if it runs fine on the home machine with XL9?


RBS











  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default data type problem XL9

Hi Peter,

I don't think missing references are the problem as this happens very early
in the code in the wb open event. I add references to the project
dynamically,
but that happens later on.
I can see though that missing references are a suspect if you say that
If "1" = 0
works on 97.
I went through the registry with this customer and
Excel\Options was only under
HKEY_CURRENT_USER\Software\Microsoft\Office\9.0\
So I think it is Excel 9.

RBS


"Peter T" <peter_t@discussions wrote in message
...
If I follow, effectively it does this (without the Val)

If "1" = 0 Then

again this works in both my XL97 & XL2k

Any missing references ?

Regards,
Peter T

"RB Smissaert" wrote in message
...
Actually the non-simplified code is:

'error he
If Val(ReadINIValueL(strINIPath, _
"Add-in behaviour", _
"F2 for load add-in")) = 0 Then


Function ReadINIValueL(ByVal strINIPath As String, _
ByVal strHeader As String, _
ByVal strKey As String) As String

Dim buf As String * 256
Dim Length As Long

If Len(Dir(strINIPath)) = 0 Then
ReadINIValueL = "<no file"
Exit Function
End If

Length = GetPrivateProfileString(strHeader, _
strKey, _
"<no value", _
buf, _
Len(buf), _
strINIPath)

ReadINIValueL = Left(buf, Length)

End Function

And the result of the function was "1" and not "<no file" or "<no
value"


RBS


"Peter T" <peter_t@discussions wrote in message
...
Just to add the example works fine in both my XL97 and XL2000, as does

the
following in both versions

Dim n As Long
n = "123"

Regards,
Peter T


"Tom Ogilvy" wrote in message
...
I suspect the customer actually is experiencing this in xl97 (xl8).
In
xl97,
you would get that error.

--
Regards,
Tom Ogilvy


"RB Smissaert" wrote:

Have come across a strange problem today with one of my customers.

In a .xla add-in I have in very much simplified code the following:

Sub test()

Dim l As Long
l = GiveString()
MsgBox l

End Sub


Function GiveString() As String

Dim s As String
s = "1"
GiveString = s

End Function

All this works fine on my 2 home PC's with XL11 and XL9.
With this one customer though in XL9 there is the error: Type

mismatch.

Why would this be if it runs fine on the home machine with XL9?


RBS










  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default data type problem XL9

This doesn't have any bearing on Bart's non-simplified code, but

I don't have xl97 handy to test, but try it this way. this works in xl2003
but I believe it will raise typemismatch in xl97.

Sub test()

Dim i As Long
i = 1
if i = GiveString() then
msgbox "match"
else
MsgBox i
end if

End Sub


Function GiveString() As String

Dim s As String
s = "1"
GiveString = s

End Function

--
Regards,
Tom Ogilvy


"Peter T" wrote:

Just to add the example works fine in both my XL97 and XL2000, as does the
following in both versions

Dim n As Long
n = "123"

Regards,
Peter T


"Tom Ogilvy" wrote in message
...
I suspect the customer actually is experiencing this in xl97 (xl8). In

xl97,
you would get that error.

--
Regards,
Tom Ogilvy


"RB Smissaert" wrote:

Have come across a strange problem today with one of my customers.

In a .xla add-in I have in very much simplified code the following:

Sub test()

Dim l As Long
l = GiveString()
MsgBox l

End Sub


Function GiveString() As String

Dim s As String
s = "1"
GiveString = s

End Function

All this works fine on my 2 home PC's with XL11 and XL9.
With this one customer though in XL9 there is the error: Type mismatch.

Why would this be if it runs fine on the home machine with XL9?


RBS







  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default data type problem XL9

Sorry, the actual code was causing the error was:

If ReadINIValueL(strINIPath, _
"Add-in behaviour", _
"F2 for load add-in") = 0 Then

So, without the Val. I had added the Val as a fix.
So, your example looks very similar and probably this is indeed an XL97
thing.

RBS


"Tom Ogilvy" wrote in message
...
This doesn't have any bearing on Bart's non-simplified code, but

I don't have xl97 handy to test, but try it this way. this works in
xl2003
but I believe it will raise typemismatch in xl97.

Sub test()

Dim i As Long
i = 1
if i = GiveString() then
msgbox "match"
else
MsgBox i
end if

End Sub


Function GiveString() As String

Dim s As String
s = "1"
GiveString = s

End Function

--
Regards,
Tom Ogilvy


"Peter T" wrote:

Just to add the example works fine in both my XL97 and XL2000, as does
the
following in both versions

Dim n As Long
n = "123"

Regards,
Peter T


"Tom Ogilvy" wrote in message
...
I suspect the customer actually is experiencing this in xl97 (xl8). In

xl97,
you would get that error.

--
Regards,
Tom Ogilvy


"RB Smissaert" wrote:

Have come across a strange problem today with one of my customers.

In a .xla add-in I have in very much simplified code the following:

Sub test()

Dim l As Long
l = GiveString()
MsgBox l

End Sub


Function GiveString() As String

Dim s As String
s = "1"
GiveString = s

End Function

All this works fine on my 2 home PC's with XL11 and XL9.
With this one customer though in XL9 there is the error: Type
mismatch.

Why would this be if it runs fine on the home machine with XL9?


RBS








  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default data type problem XL9

That also works in my XL 97, I got "match". I don't recall this particular
type of coercion not working in XL97.

?"1" = 1&
True

Regards,
Peter T

"Tom Ogilvy" wrote in message
...
This doesn't have any bearing on Bart's non-simplified code, but

I don't have xl97 handy to test, but try it this way. this works in

xl2003
but I believe it will raise typemismatch in xl97.

Sub test()

Dim i As Long
i = 1
if i = GiveString() then
msgbox "match"
else
MsgBox i
end if

End Sub


Function GiveString() As String

Dim s As String
s = "1"
GiveString = s

End Function

--
Regards,
Tom Ogilvy


"Peter T" wrote:

Just to add the example works fine in both my XL97 and XL2000, as does

the
following in both versions

Dim n As Long
n = "123"

Regards,
Peter T


"Tom Ogilvy" wrote in message
...
I suspect the customer actually is experiencing this in xl97 (xl8).

In
xl97,
you would get that error.

--
Regards,
Tom Ogilvy


"RB Smissaert" wrote:

Have come across a strange problem today with one of my customers.

In a .xla add-in I have in very much simplified code the following:

Sub test()

Dim l As Long
l = GiveString()
MsgBox l

End Sub


Function GiveString() As String

Dim s As String
s = "1"
GiveString = s

End Function

All this works fine on my 2 home PC's with XL11 and XL9.
With this one customer though in XL9 there is the error: Type

mismatch.

Why would this be if it runs fine on the home machine with XL9?


RBS









  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default data type problem XL9

Sub aaa()
ActiveCell.Value = "a"
If ActiveCell.Value = 1 Then
MsgBox "Equals 1"
Else
MsgBox "Doesn't equal 1"
End If

End Sub

Fails in xl97 with a type mismatch, but works in xl2002, xl2000 (at least
for me)

I don't know all the combinations that will cause it to fail in xl97 and not
xl2000/2 but I know xl97 is more sensitive to this.

May have no bearing on Bart's problem, but then again maybe it does.

--
Regards,
Tom Ogilvy


"Peter T" <peter_t@discussions wrote in message
...
That also works in my XL 97, I got "match". I don't recall this particular
type of coercion not working in XL97.

?"1" = 1&
True

Regards,
Peter T

"Tom Ogilvy" wrote in message
...
This doesn't have any bearing on Bart's non-simplified code, but

I don't have xl97 handy to test, but try it this way. this works in

xl2003
but I believe it will raise typemismatch in xl97.

Sub test()

Dim i As Long
i = 1
if i = GiveString() then
msgbox "match"
else
MsgBox i
end if

End Sub


Function GiveString() As String

Dim s As String
s = "1"
GiveString = s

End Function

--
Regards,
Tom Ogilvy


"Peter T" wrote:

Just to add the example works fine in both my XL97 and XL2000, as does

the
following in both versions

Dim n As Long
n = "123"

Regards,
Peter T


"Tom Ogilvy" wrote in message
...
I suspect the customer actually is experiencing this in xl97 (xl8).

In
xl97,
you would get that error.

--
Regards,
Tom Ogilvy


"RB Smissaert" wrote:

Have come across a strange problem today with one of my customers.

In a .xla add-in I have in very much simplified code the following:

Sub test()

Dim l As Long
l = GiveString()
MsgBox l

End Sub


Function GiveString() As String

Dim s As String
s = "1"
GiveString = s

End Function

All this works fine on my 2 home PC's with XL11 and XL9.
With this one customer though in XL9 there is the error: Type

mismatch.

Why would this be if it runs fine on the home machine with XL9?


RBS













  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default data type problem XL9

Maybe it was XL 8. Will find out tomorrow.
For now I have added Val to the string variables as with that it seems fine,
even on this customer's PC.
So:
l = Val(GiveString())

RBS

"Tom Ogilvy" wrote in message
...
I suspect the customer actually is experiencing this in xl97 (xl8). In
xl97,
you would get that error.

--
Regards,
Tom Ogilvy


"RB Smissaert" wrote:

Have come across a strange problem today with one of my customers.

In a .xla add-in I have in very much simplified code the following:

Sub test()

Dim l As Long
l = GiveString()
MsgBox l

End Sub


Function GiveString() As String

Dim s As String
s = "1"
GiveString = s

End Function

All this works fine on my 2 home PC's with XL11 and XL9.
With this one customer though in XL9 there is the error: Type mismatch.

Why would this be if it runs fine on the home machine with XL9?


RBS





  #12   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default data type problem XL9

Can comfirm now that this was on Excel 9 (2000), so maybe the trouble
is somehow caused by a missing reference.
Strange though that when I was debugging over the phone adding Val
fixed at least the error on that line.

RBS


RB Smissaert wrote:
Maybe it was XL 8. Will find out tomorrow.
For now I have added Val to the string variables as with that it seems fine,
even on this customer's PC.
So:
l = Val(GiveString())

RBS

"Tom Ogilvy" wrote in message
...
I suspect the customer actually is experiencing this in xl97 (xl8). In
xl97,
you would get that error.

--
Regards,
Tom Ogilvy


"RB Smissaert" wrote:

Have come across a strange problem today with one of my customers.

In a .xla add-in I have in very much simplified code the following:

Sub test()

Dim l As Long
l = GiveString()
MsgBox l

End Sub


Function GiveString() As String

Dim s As String
s = "1"
GiveString = s

End Function

All this works fine on my 2 home PC's with XL11 and XL9.
With this one customer though in XL9 there is the error: Type mismatch.

Why would this be if it runs fine on the home machine with XL9?


RBS





  #13   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default data type problem XL9

I'm sure you've double checked but if the string returns an extra non
numeric character, perhaps non-printable & not obvious, it would be fixed
with use of Val.

String functions are particularly sensitive to missing references. Although
one is not used directly maybe a string function is used invisibly to
perform the coercion, I don't know.

I'm not sure that upgrading to 2003 will guarantee to fix the problem.

Regards,
Peter T

wrote in message
oups.com...
Can comfirm now that this was on Excel 9 (2000), so maybe the trouble
is somehow caused by a missing reference.
Strange though that when I was debugging over the phone adding Val
fixed at least the error on that line.

RBS


RB Smissaert wrote:
Maybe it was XL 8. Will find out tomorrow.
For now I have added Val to the string variables as with that it seems

fine,
even on this customer's PC.
So:
l = Val(GiveString())

RBS

"Tom Ogilvy" wrote in message
...
I suspect the customer actually is experiencing this in xl97 (xl8). In
xl97,
you would get that error.

--
Regards,
Tom Ogilvy


"RB Smissaert" wrote:

Have come across a strange problem today with one of my customers.

In a .xla add-in I have in very much simplified code the following:

Sub test()

Dim l As Long
l = GiveString()
MsgBox l

End Sub


Function GiveString() As String

Dim s As String
s = "1"
GiveString = s

End Function

All this works fine on my 2 home PC's with XL11 and XL9.
With this one customer though in XL9 there is the error: Type

mismatch.

Why would this be if it runs fine on the home machine with XL9?


RBS







  #14   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default data type problem XL9

Yes, good point, but the result of that ini function in that particular case
only
can be "1" or "0".
Must admit though I haven't seen the actual return when it runs.
As this customer has XL9 the whole issue of Type mismatch in XL8 versus 9
is now irrelevant and I will have to look somewhere else.
Had a look in my customer database and I have nobody on XL8, so maybe I can
throw all those Val's out again.
My guess is that indeed it somehow has to do with references.
Will have to wait till next week to find out.

RBS


"Peter T" <peter_t@discussions wrote in message
...
I'm sure you've double checked but if the string returns an extra non
numeric character, perhaps non-printable & not obvious, it would be fixed
with use of Val.

String functions are particularly sensitive to missing references.
Although
one is not used directly maybe a string function is used invisibly to
perform the coercion, I don't know.

I'm not sure that upgrading to 2003 will guarantee to fix the problem.

Regards,
Peter T

wrote in message
oups.com...
Can comfirm now that this was on Excel 9 (2000), so maybe the trouble
is somehow caused by a missing reference.
Strange though that when I was debugging over the phone adding Val
fixed at least the error on that line.

RBS


RB Smissaert wrote:
Maybe it was XL 8. Will find out tomorrow.
For now I have added Val to the string variables as with that it seems

fine,
even on this customer's PC.
So:
l = Val(GiveString())

RBS

"Tom Ogilvy" wrote in message
...
I suspect the customer actually is experiencing this in xl97 (xl8).
In
xl97,
you would get that error.

--
Regards,
Tom Ogilvy


"RB Smissaert" wrote:

Have come across a strange problem today with one of my customers.

In a .xla add-in I have in very much simplified code the following:

Sub test()

Dim l As Long
l = GiveString()
MsgBox l

End Sub


Function GiveString() As String

Dim s As String
s = "1"
GiveString = s

End Function

All this works fine on my 2 home PC's with XL11 and XL9.
With this one customer though in XL9 there is the error: Type

mismatch.

Why would this be if it runs fine on the home machine with XL9?


RBS








Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Type mismatch problem Dan Excel Programming 7 May 31st 06 04:55 PM
Data Type Problem!!! Addy Excel Programming 2 May 14th 06 02:33 PM
Data Type Problem? bailey Excel Discussion (Misc queries) 8 December 6th 05 03:51 AM
Data type problem - ODBC Excel '97-2000 Driver Ryan Excel Programming 2 May 27th 04 09:19 PM
Excel VBA - Data Type Conversion problem PaulC Excel Programming 3 May 10th 04 04:53 PM


All times are GMT +1. The time now is 12:40 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"