OberonPlace.com Forums  

Go Back   OberonPlace.com Forums > Developer Forums > VBA > CorelDRAW/Corel DESIGNER VBA

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 19-05-2010, 17:20
runflacruiser's Avatar
runflacruiser runflacruiser is offline
Senior Member
 
Join Date: Jun 2009
Location: Pigeon Forge, TN USA
Posts: 811
Default vba Left not working

Hi.

I have a module I am using to build a function. In this I'm using something like this example:
Code:
dim str as string, myOtherString as string
myOtherSring = "test"
str = Left(myOtherString , 1)
msgbox str ' should be "t"
and it doesn't work. I get error:

Compile error:
Wrong number of arguments or invalid property assignment.

I even tried:
Code:
MsgBox Left("test", 1)
in the intermediate window of this module and still no dice.

The funny thing is that it works fine in another module.
I tried sub, private sub and still no.

Here's a similar reference I found
reference1

reference 2

Has anyone had a similar experience with this?
-John
Reply With Quote
  #2  
Old 19-05-2010, 17:40
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,788
Blog Entries: 12
Send a message via ICQ to shelbym Send a message via AIM to shelbym Send a message via MSN to shelbym Send a message via Yahoo to shelbym
Default str

str is a built in function, you can't use it. :-)

Also myOtherSring = "test" you forgot the r, Option Explicit will help catch this type of error. :-)

-Shelby

Last edited by shelbym; 19-05-2010 at 17:44.
Reply With Quote
  #3  
Old 19-05-2010, 19:32
runflacruiser's Avatar
runflacruiser runflacruiser is offline
Senior Member
 
Join Date: Jun 2009
Location: Pigeon Forge, TN USA
Posts: 811
Default

HI Shelby.
Oops, Cause I typed that example in the forum box, not copy and pasted from actual code.

Here's the sub (soon to be function.)
I'm guessing you'll know what it's for.
I want to validate a string beginning with a specified range of letters, and set and ultimately return the boolean.

Just in case you know a shorter, faster way, I'd love to hear it. It works fine, I think. I haven't really tested because the left function not working in this module is bugging me...lol

Str function?

Code:
Option Explicit

Sub test()

End Sub
Sub letterPass()
    'soon to be a function ' ()as boolean
    Dim fontName As String, startLet As String, endLet As String
    Dim abcArr As Variant
    Dim letter As String
    Dim startKey As Long, endKey As Long
    Dim pass As Boolean
    Dim i As Integer, j As Integer, k As Integer
    
    
    pass = False 'flag set
    
    startLet = "@": endLet = "0"
    fontName = "@try"

    letter = Left(fontName, 1) 'not working...hmmmmmm
    'letter = "@" 'for testing
    
    'may move array outside function for more speed. This is for now.
    abcArr = Split("@ # ! ? ( ) * . 0 1 2 3 4 5 6 7 8 9 0 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z")

    'get start key
    For i = 0 To UBound(abcArr)
       If abcArr(i) = startLet Then startKey = i
    Next i
    
    'get end key if set. This will be an optional param of the function.
    If endLet <> "" Then
        For j = 0 To UBound(abcArr)
           If abcArr(j) = endLet Then endKey = j
        Next j
    Else
        endKey = startKey
    End If
    
    'check fontname against each first letter value in range
    For k = startKey To endKey
        If UCase(letter) = abcArr(k) Or LCase(letter) = abcArr(k) Then pass = True
    Next k
    
    MsgBox pass 'is the fname inbetween the specified letter range
End Sub
-John
Reply With Quote
  #4  
Old 19-05-2010, 21:47
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,788
Blog Entries: 12
Send a message via ICQ to shelbym Send a message via AIM to shelbym Send a message via MSN to shelbym Send a message via Yahoo to shelbym
Default Str

Quote:
Originally Posted by runflacruiser View Post
Str function?
Str Function

Returns a Variant (String) representation of a number.

Dim MyString
MyString = Str(459) ' Returns " 459".
MyString = Str(-459.65) ' Returns "-459.65".
MyString = Str(459.001) ' Returns " 459.001".

-Shelby
Reply With Quote
  #5  
Old 19-05-2010, 21:54
runflacruiser's Avatar
runflacruiser runflacruiser is offline
Senior Member
 
Join Date: Jun 2009
Location: Pigeon Forge, TN USA
Posts: 811
Default

Quote:
Originally Posted by shelbym View Post
str is a built in function, you can't use it. :-)

-Shelby
Hi.
I know. I thought you meant you could use it to replace the left function. That's why it had me confused.

-John
Reply With Quote
  #6  
Old 19-05-2010, 22:00
runflacruiser's Avatar
runflacruiser runflacruiser is offline
Senior Member
 
Join Date: Jun 2009
Location: Pigeon Forge, TN USA
Posts: 811
Default

...I'm laughing hard now..

I misread your "can't" for can.

Yea. I just quick typed in the example without thinking. It's not the same as the code I actually used...lol

-John

EDIT: Thanks, I did find that I used it in some other code in the FC macro. It still worked good though.

Last edited by runflacruiser; 19-05-2010 at 22:05. Reason: found str in FC macro function pagefonts()
Reply With Quote
  #7  
Old 21-05-2010, 10:17
biok
Guest
 
Posts: n/a
Default try this...

Give it a try like this
Code:
VBA.Left(string,length)
I had the same issue, and some guy in a Vba Exel forum recomend me to use the "VBA" keyWord before those string function that didn't worked for me and now it work just fine.
Hope that help you.
Reply With Quote
  #8  
Old 21-05-2010, 10:20
runflacruiser's Avatar
runflacruiser runflacruiser is offline
Senior Member
 
Join Date: Jun 2009
Location: Pigeon Forge, TN USA
Posts: 811
Default

Quote:
Originally Posted by biok View Post
Give it a try like this
Code:
VBA.Left(string,length)
I had the same issue, and some guy in a Vba Exel forum recomend me to use the "VBA" keyWord before those string function that didn't worked for me and now it work just fine.
Hope that help you.
Ah. Thank you very much. Worked like a charm.
-John
Reply With Quote
Reply

Tags
vba left


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Working with Excel nic CorelDRAW/Corel DESIGNER VBA 3 03-05-2010 09:00
Ruler to start top left of page instead of bottom left fungel General 2 08-04-2009 12:07
winAPI to capture a left-click? Rick Randall CorelDRAW/Corel DESIGNER VBA 3 24-07-2007 12:38
Name Property not working ddonnahoe CorelDRAW/Corel DESIGNER VBA 2 02-01-2007 12:31
ConvertToCurves not working. rsriram22 CorelDRAW/Corel DESIGNER VBA 2 29-06-2006 09:40


All times are GMT -5. The time now is 20:02.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.
Copyright © 2011, Oberonplace.com