Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 206
Default type mismatch?

hi all!

i have a sub defined in a module:
public sub myFunc(a as string, b as string, optional c as integer, optional
d as label)
.....
end sub

calling this from a userform:

call myFunc(a,b,c,d)

where
a and b are TextBox (defined in the UserForm)
c is an integer defined private c as integer
d is a Label (defined in the userform)

all variables have a value

i am getting a type mismatch error on this call
call myFunc(a,b,c,d)
..... why?
(i have also tried a.value, a.text, cstr(a) and that hasn't worked. i've
also tried cint(c)

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default type mismatch?

try

public sub myFunc(a as string, b as string, _
optional c as integer, optional d as Object)


--
Regards,
Tom Ogilvy




"Gixxer_J_97" wrote in message
...
hi all!

i have a sub defined in a module:
public sub myFunc(a as string, b as string, optional c as integer,

optional
d as label)
....
end sub

calling this from a userform:

call myFunc(a,b,c,d)

where
a and b are TextBox (defined in the UserForm)
c is an integer defined private c as integer
d is a Label (defined in the userform)

all variables have a value

i am getting a type mismatch error on this call
call myFunc(a,b,c,d)
.... why?
(i have also tried a.value, a.text, cstr(a) and that hasn't worked. i've
also tried cint(c)



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 983
Default type mismatch?

If that doesn't work... (Probably will. Tom is usually right...) try

public sub myFunc(a as variant, b as variant, optional c as variant, optional
d as variant)

And then place a watch on a, b, c, and d just to see what you really have
passed. It can be easy to pass the wrong thing.

HTH


"Tom Ogilvy" wrote:

try

public sub myFunc(a as string, b as string, _
optional c as integer, optional d as Object)


--
Regards,
Tom Ogilvy




"Gixxer_J_97" wrote in message
...
hi all!

i have a sub defined in a module:
public sub myFunc(a as string, b as string, optional c as integer,

optional
d as label)
....
end sub

calling this from a userform:

call myFunc(a,b,c,d)

where
a and b are TextBox (defined in the UserForm)
c is an integer defined private c as integer
d is a Label (defined in the userform)

all variables have a value

i am getting a type mismatch error on this call
call myFunc(a,b,c,d)
.... why?
(i have also tried a.value, a.text, cstr(a) and that hasn't worked. i've
also tried cint(c)




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 206
Default type mismatch?

thanks guys - the 'object' worked

i guess my question now is why it wouldn't work with Label?



"Jim Thomlinson" wrote:

If that doesn't work... (Probably will. Tom is usually right...) try

public sub myFunc(a as variant, b as variant, optional c as variant, optional
d as variant)

And then place a watch on a, b, c, and d just to see what you really have
passed. It can be easy to pass the wrong thing.

HTH


"Tom Ogilvy" wrote:

try

public sub myFunc(a as string, b as string, _
optional c as integer, optional d as Object)


--
Regards,
Tom Ogilvy




"Gixxer_J_97" wrote in message
...
hi all!

i have a sub defined in a module:
public sub myFunc(a as string, b as string, optional c as integer,

optional
d as label)
....
end sub

calling this from a userform:

call myFunc(a,b,c,d)

where
a and b are TextBox (defined in the UserForm)
c is an integer defined private c as integer
d is a Label (defined in the userform)

all variables have a value

i am getting a type mismatch error on this call
call myFunc(a,b,c,d)
.... why?
(i have also tried a.value, a.text, cstr(a) and that hasn't worked. i've
also tried cint(c)




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default type mismatch?

Read the help on Function under the description of Optional, then below that
look at the as type narrative.


--
Regards,
Tom Ogilvy


"Gixxer_J_97" wrote in message
...
thanks guys - the 'object' worked

i guess my question now is why it wouldn't work with Label?



"Jim Thomlinson" wrote:

If that doesn't work... (Probably will. Tom is usually right...) try

public sub myFunc(a as variant, b as variant, optional c as variant,

optional
d as variant)

And then place a watch on a, b, c, and d just to see what you really

have
passed. It can be easy to pass the wrong thing.

HTH


"Tom Ogilvy" wrote:

try

public sub myFunc(a as string, b as string, _
optional c as integer, optional d as Object)


--
Regards,
Tom Ogilvy




"Gixxer_J_97" wrote in message
...
hi all!

i have a sub defined in a module:
public sub myFunc(a as string, b as string, optional c as integer,
optional
d as label)
....
end sub

calling this from a userform:

call myFunc(a,b,c,d)

where
a and b are TextBox (defined in the UserForm)
c is an integer defined private c as integer
d is a Label (defined in the userform)

all variables have a value

i am getting a type mismatch error on this call
call myFunc(a,b,c,d)
.... why?
(i have also tried a.value, a.text, cstr(a) and that hasn't worked.

i've
also tried cint(c)






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--how to fix rroach Excel Discussion (Misc queries) 2 July 14th 05 06:23 PM
Type Mismatch teresa Excel Programming 10 December 28th 04 10:14 PM
Type mismatch teresa Excel Programming 1 December 14th 04 11:19 PM
Type mismatch? John Wirt[_9_] Excel Programming 6 December 11th 04 09:37 PM
Type mismatch Patti[_5_] Excel Programming 3 May 30th 04 02:44 PM


All times are GMT +1. The time now is 11:00 AM.

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

About Us

"It's about Microsoft Excel"