Right$ ,left$ mid$ don't work anymore 
Author Message
 Right$ ,left$ mid$ don't work anymore

Hi

whenever I use right, left and mid function s I get the following message

Type declaration character does not match declared data type

and I have checked my programs inside out but cannot find what is causing
it. These functions are within classes and they use to work.

this has to be something obvious that I am just missing . I hope

eg. In the following procedures both psubkey and Path are defined as strings

        If Left$(psubkey, 1) <> "\" Then
                psubkey = "\" & psubkey
        End If

Public Function verifyFilePath(Path As String) As String
If Right$(Path, 1) <> "\" Then
        Path = Path & "\"
End If
        verifyFilePath = Path
End Function

Thanks

The Wizzard



Fri, 13 Apr 2001 03:00:00 GMT  
 Right$ ,left$ mid$ don't work anymore
This is almost always caused by a missing or misplaced reference to VBA.
Check your "Project... References" for this project against one you know
works OK.

--
     Jim Mack
     MicroDexterity, Inc

     http://www.microdexterity.com




Quote:
>Hi

>whenever I use right, left and mid function s I get the following message

>Type declaration character does not match declared data type

>and I have checked my programs inside out but cannot find what is causing
>it. These functions are within classes and they use to work.



Fri, 13 Apr 2001 03:00:00 GMT  
 Right$ ,left$ mid$ don't work anymore
This seems to happen do to an internal VB problem with scope. TRy putting
vba. infront of these cmmands and see if they work now.

Quote:
>Hi

>whenever I use right, left and mid function s I get the following message

>Type declaration character does not match declared data type

>and I have checked my programs inside out but cannot find what is causing
>it. These functions are within classes and they use to work.

>this has to be something obvious that I am just missing . I hope

>eg. In the following procedures both psubkey and Path are defined as
strings

>        If Left$(psubkey, 1) <> "\" Then
>                psubkey = "\" & psubkey
>        End If

>Public Function verifyFilePath(Path As String) As String
>If Right$(Path, 1) <> "\" Then
>        Path = Path & "\"
>End If
>        verifyFilePath = Path
>End Function

>Thanks

>The Wizzard



Fri, 13 Apr 2001 03:00:00 GMT  
 Right$ ,left$ mid$ don't work anymore
You are calling the function from within the function. Remove
verifyFilePath = Path from the function.


Quote:
>Hi

>whenever I use right, left and mid function s I get the following message

>Type declaration character does not match declared data type

>and I have checked my programs inside out but cannot find what is causing
>it. These functions are within classes and they use to work.

>this has to be something obvious that I am just missing . I hope

>eg. In the following procedures both psubkey and Path are defined as
strings

>        If Left$(psubkey, 1) <> "\" Then
>                psubkey = "\" & psubkey
>        End If

>Public Function verifyFilePath(Path As String) As String
>If Right$(Path, 1) <> "\" Then
>        Path = Path & "\"
>End If
>        verifyFilePath = Path
>End Function

>Thanks

>The Wizzard



Fri, 13 Apr 2001 03:00:00 GMT  
 Right$ ,left$ mid$ don't work anymore

Quote:

>whenever I use right, left and mid function s I get the following message

>Type declaration character does not match declared data type

>and I have checked my programs inside out but cannot find what is causing
>it. These functions are within classes and they use to work.

>this has to be something obvious that I am just missing . I hope

>eg. In the following procedures both psubkey and Path are defined as strings

>        If Left$(psubkey, 1) <> "\" Then
>                psubkey = "\" & psubkey
>        End If

>Public Function verifyFilePath(Path As String) As String
>If Right$(Path, 1) <> "\" Then
>        Path = Path & "\"
>End If
>        verifyFilePath = Path
>End Function

How are you calling the functions/subs? There isn't anything wrong with the
code you show above, but there might be a problem in how you're calling
them. For instance, I can duplicate the error message you're getting if I
set a variable, say xVar = "somepath" without 'option explicit' turned on.
That way, xVar is a variant, not a string.

Then if I do something (admittedly odd) like calling verifyFilePath like so:

strNewPath = verifyFilePath(xVar$)

the error you are seeing will be generated because the $ type declaration
character is trying to turn the variant into a string to send to the
function, and not succeeding.

If I send a true string, ie - Dim xVar As String and then call the function
simply as: strNewPath = verifyFilePath(xVar), then everything runs properly.

By the way, as long as you are messing with Path inside the func, and path
is (by default) passed byRef, you don't really need to return the value with
your - verifyFilePath = Path line. You can turn the whole thing into a sub.
The string parameter you sent to the function will have the "\" on the end
when the call is finished.

Alan



Sat, 14 Apr 2001 03:00:00 GMT  
 Right$ ,left$ mid$ don't work anymore
I always use option explicit however I think that you are fairly close as
there must be some bad variable in the code so I will have to go through it
variable by variable.
I know the code worked well until I got clever again and tried to update it.

thanks



Sat, 14 Apr 2001 03:00:00 GMT  
 Right$ ,left$ mid$ don't work anymore
I just clicked on the definition of Left and found that it was being
referenced back to an enumeration from a user control I had written instead
of VBA functions.

Another reason why you should NEVER name enum constants with similar names
to functions.

I recompiled the control with new enum names and everything is great



Sat, 14 Apr 2001 03:00:00 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. String extract functions, left,right.mid don't work

2. drop-downs don't work anymore

3. Frame in IE 30 don't work anymore

4. Mid, Left, Right String functions fail if any library is missing

5. mid/left/right equivs??

6. Speed difference -- mid/left/right

7. LEFT$, RIGHT$, MID$ Equivalents?

8. Left$,Mid$,Right$

9. LEFT,RIGHT, and MID Functions

10. Migration CR6 to CR7: Reports don′t work anymore

11. Right aligned text boxes don't right align

12. Don't get post anymore

 

 
Powered by phpBB® Forum Software